Hello,
I want to use data 'theID' from a PostgreSQL-RETURNING statement
INSERT INTO ... RETURNING theID;
further in another statement. How can this be done (without cursors)?
My full statement (copying some data and delete them from source table; tab1 & tab2 definition are equal):
DELETE FROM tab1 WHERE tab1id IN
(
INSERT INTO tab2
SELECT * FROM tab1 WHERE ?something?
RETURNING tab2id
);
The error message:
ERROR: Syntaxerror near »INTO«
LINE 7: DELETE FROM tab1 WHERE tab1id IN (INSERT INTO tab2 SELECT * FROM ...
^
Thanks, Tebas.