vendredi 22 avril 2016

Can I use if statements in a stored procedure to insert values into a table?

I am trying to write a stored procedure that selects indiv_ids and transaction_ids and inserts these into a table on my schema. In doing so, I want to pass in variables and have the stored procedure use if statements to select the indiv_ids and transaction_ids from different tables depending on the information passed in. I've tried a few variations and can't get the procedure to work without an error. Thanks!

 create or replace procedure myproc (name_type in number, dept in number)
 is begin 
 if name_type='promo' then insert into mytable(indiv_id,transaction_id)
 ---sql here; 
 commit;
 elsif name_type='deal' then insert into mytable(indiv_id, transaction_id)
 ---sql here;
 commit;
 end if;
 end;

Aucun commentaire:

Enregistrer un commentaire