last_insert_id oracle

1

I have a question about oracle bank.

I created two tables and set one of them with a field with foreing key (see below FK)

tbl_city * id_city * (PK and auto increment) - generated with sequence since we do not have auto_increment in oracle

municipality

tbl_children cod (PK)

school

* id_city (FK) *

How the heck am I putting an INSERT to populate both tables? Until then I just put insert's to a table in oracle.

    
asked by anonymous 15.02.2014 / 13:42

1 answer

2

Use the RETURNING clause in your INSERT command:

INSERT INTO tbl_cidade (...) VALUES (...) RETURNING id_city INTO var_id;

Then use var_id in the INSERT of the tbl_table.

    
15.02.2014 / 13:48