I
I
ivandao2019-11-26 11:01:19
Oracle
ivandao, 2019-11-26 11:01:19

How to organize transactions with returning?

There are several tables with related data.
The data is linked by id.
After adding data to the first table, the row id is formed and the data is returned via returning to add it to other tables.
Table | ID | val |
example: Returning example:

INSERT INTO table (val) VALUES ( 'data' ) RETURNING ID

All this business I wanted to make in transaction.
How there to receive value from returning?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2019-11-26
@ivandao

I didn’t quite understand what the question was, but in order to do it within one transaction, you need to wrap everything in begin end

begin 
insert into ..... returning id into :id; 
-- ...
commit;
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question