I try to do this, but it’s a syntax error, what am I doing wrong?
declare myid := insert into oameni values(default,'lol') returning id;
my table:
create table oameni
(
id serial primary key,
name varchar(10)
);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to use the INTO clause in the RETURNING to set the value being returned into your variable:
You also need to specify the data type of your variable; I’m glad to see postgresql supports %TYPE and %ROWTYPE.