Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get field ID from trigger

Johnny BMar 12 2019 — edited Mar 12 2019

Hi All,

I got this import solution:

Bulk Insert from webapp

Trying to get sequence number and field id in from trigger before insert.

The excel csv file contains three fields:

DATE, PROGRAM, COST

The table structure is:

CREATE TABLE "MYDB"."ME_TEST"

   ("ME_ID" NUMBER,

    "ME_DATE" DATE NOT NULL ENABLE,

    "UNIT_PROGRAM_ID" NUMBER,

    "COST" NUMBER);

Need to create the sequence for ME_ID field and find the program_id from PROGRAM table and store the program_id in this table using the trigger

create or replace trigger getAllKeys

  before insert

  on ME_TEST

  for each row

declare

  v_program_id  numeric;

begin

 

  if :new.ME_ID is null then

     select Sq_Me_Id.Nextval into :new.ME_ID

     from dual;

  end if;

 

  select unit_program_id into v_program_id

  from unit_program

  where unit_program_name = XXX ;

 

  :new.unit_program_id = v_program_id;

 

end ;

How can I pass the excel PROGRAM field value to the XXX in the where statement?

Thanks,

Johnny

Using Oracle Database 12c Enterprise Edition Release 12.1.0.2.0

This post has been answered by Mustafa KALAYCI on Mar 12 2019
Jump to Answer
Comments
Post Details
Added on Mar 12 2019
7 comments
871 views