I’m trying to work out how to do a single SQL query which inserts a new row then displays the insert as confirmation.
Is there anyway to do this in one SQL query without using prepared statements or putting it into java?
These are the two queries seperately:
I’m using Postgres database and PGadmin to run the queries.
INSERT INTO Log (ID, LogType, Status, Priority, LoggedTime, UserID, ProblemID)
VALUES (2, 'test', 'test', 3, '2012-03-1
4 10:30', 2, 1);
SELECT * FROM Log WHERE ID = 2;
edit: the ID is inserted each time and is not in a sequence
Use the
RETURNINGclause: