I’m inserting data into table and I want to get last id which will be later used for another query.
Here is table structure and query sql-fiddle
I’m receiving this error
ERROR: syntax error at end of input Position: 890
What could be wrong in insert statement?
2
Answers
In all DBMS, when you declare a "view" using the with … as () syntax, you are expected to use it immediately. If you try to execute only the with … as () construct, you will get an error and PostgreSQL will wait for you to complete the query.
You have two options: either remove the "with" construct and obtain the result of your "returning" clause, or append a query to the "view" created through with … as () to read its contents, as follows:
From Doc:
I hope this helps!
sql-fiddle