I currently have a trigger (with a sequence) set on the VALUE table that auto-generates a new value_id every time a row is inserted into the table. I am trying to return that new value_id (generated by the trigger/sequence) into a variable so that I can use it in an insert into a relationship table later in the proc.
However, when I use the returning
statement, Oracle returns an error. When I use a traditional insert, the code seems to run/compile just fine.
Do you know what I may be doing wrong? Below is an abridged version of the code that I wrote:
insert into value
(value_id,
energy_product_id,
data_source_id,
unit_cd,
value_tx,
hr
)
select null,
energy_product_id,
data_source_id,
unit_cd,
value_tx
from value
returning value_id into v_value_id;
Thanks in Advance
**EDIT: ** Below is the code with the discussed changes. It errors out however:
insert into value
(value_id,
energy_product_id,
data_source_id,
unit_cd,
value_tx,
hr
)
select (select seq_sample.nextval from dual),
energy_product_id,
data_source_id,
unit_cd,
value_tx
from value
returning value_id into v_value_id;