Based on previous answers I realised that it failfails for the firtsfirst value added , the: The query returns 2 instead on 1 when there are no values added,. hereHere is my solution.:
SELECT (CASE WHEN is_called THEN last_value + i.inc
ELSE last_value END ) AS nextvalue
FROM myserial,
(SELECT seqincrement AS inc
FROM pg_sequence
WHERE seqrelid = 'myserial'::regclass::oid) AS i;