Recover value of sequence in customSQL : insert ..

Hello,

I have this customSQL : insert into ADERTRANSCO values (?,?,SEQUENCE1.nextval) and i want to recover the value of the oracle sequence in the output file.

How do i procced ?

Thank

How I’ve done this in the past:

  • Call select service to get SEQUENCE1.nextval
  • Call insert service, setting the appropriate field with the value retrieved

That way you have the value to use for other purposes.

Thank for your reply, but i don’t want to do this in 2 adapters service but only in 1.

I want to user the returning clause the SQL insert :

RETURNING expr [, expr ]…INTO data_item [, data_item ]…

like this

inert into tab(a,b) values (‘xxx’,seq.nextval) returning(seq.currval) into yyy

1 Like

I know that using one service is desirable. I have not found a way to do so. The 2 services approach worked just fine for me so I didn’t pursue any further. Is there an objection to doing 2 services instead of just one other than preference?

I would think using seq.curval is risky because another thread may update it between your nextval and curval calls.

Perhaps you can reference the column that is populated with the seq value in the returning clause. But I’m not even certain the JDBC adapter service (insert or custom) supports the returning clause. Perhaps it does and that will do the trick for you.

u can have a procedure which takes in the input does an insert and gives the sequence as the output.

What do you mean by ‘procedure’ ?

A pl/sql procedue ? If you mean’s flow service, i don’t know how to do put the sequence value in the output.

To reamon : i’m agree whith you : it’s not possible to using the returning clause of insert wtih a JDBC Adapter.

have a db personnel create a procedure, create an adapter service “procedure with signature” and select the procedure from the dropdown. It will automatically give u the list of inputs and the outputs (seq no in our case).

thanks pilaire,
with solution is OK.

But I need to have a list of data in my input in addition to have the sequence in the output.

as TYPE G_TT_lg_CDMONTANT IS TABLE OF varchar2(100) INDEX BY BINARY_INTEGER;

i’m don’t see them.