Link to home
Start Free TrialLog in
Avatar of aaba646
aaba646Flag for United States of America

asked on

How to insert values in a table based on a flag condition which output of a select query inside a stored procedure

Hi, I have a package which consists following procedure:

PROCEDURE sp_abc(in_user_id IN VARCHAR2,
             in_code_id IN INTEGER,
             out_cursor OUT E_CURSOR)
IS
BEGIN
OPEN out_cursor FOR

<SELECT query>

<IF flag is Y, for one of the column> THEN

INSERT into table xyz
COMMIT;
END IF;
END sp_abc;

E_CURSOR is weak cursor.This cursor returns record set which is used by VB application.
Inside the procedure how can i select a field from out of select query for which flag is Y
and based on that i have to insert values in different table.

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of sathyagiri
sathyagiri
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cjard
cjard

What relation are the SELECT query and the xyz table? Is the data related?

You can use a MERGE statement for this work, but it depends how you will handle values that are already present. If you want a new record to be inserted even though one already exists, you cannot use a merge. If it is important that no duplicates are inserted, a merge would be the best way
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin