I don't understand how to use RETURNING
, e.g. how to get the actual value "in my hands" for next steps. Assume, I have two tables:
create table "actors" (
id_act serial not null primary key,
first_name text not null,
last_name text not null
);
create table movies (
id_mov serial not null primary key,
act_id integer not null
);
Now I add an actor:
INSERT INTO actors (first_name, last_name) VALUES ('Tom', 'Hanks');
and immediately after that, I'd like to use that new actor's-ID to insert a movie:
INSERT INTO movies(###);
How can I use RETURNING
to use it instead of my placeholder ###?