Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging data from two cursors 1

Status
Not open for further replies.

TimboA

MIS
Jul 12, 2001
38
GB
I need to be able to merge the data from two cursors into one record for example :-

Cursor Fred contains Record A which consists of an account number and name & address details.
Cursor Mary contains Record A which consists of an account number (same one as in Fred's Record A) and balance details.

I need one record :- Account number, name & address and balance details.

Anyone tell me the best way to do this ?

Thanks folks.
 
I would nest the cursors and open the child cursor for each record in the parent cursor:

CURSOR FRED IS
SELECT account_number, address_details FROM my_table;

CURSOR MARY (p_acct NUMBER) IS SELECT balance_details FROM my_other_table
WHERE account_number = p_acct;

BEGIN
FOR i IN fred LOOP
FOR j IN mary(i.account_number) LOOP
-- NOW YOU CAN SYNTHESIZE A SINGLE RECORD
-- WITH i.account_number, i.address_details,
-- j.balance_details
END LOOP;
END LOOP;
END;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top