Thanks for your reply! yeath,I quite accept your opinion,once i guess the drive adds savepoint between the two SQL,but not sure i want to get the last insert id to ensure the INSERT correctly ,so i called currval(). as the error occurs seldom,i find it's difficult to trace the problem or the logic is doing exactly later i modified the code looks like: >select nexval('t_wedding_wedding_id_seq') as Wedding_id; >insert into t_wedding(wedding_id...) select Wedding_id...; and in the later pressure tesing never saw the error again. ----- God believes postgres is Good -- View this message in context: http://postgresql.1045698.n5.nabble.com/currval-of-sequence-xxx-seq-is-not-yet-defined-in-this-session-tp5738893p5739294.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general