Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> extracting records using a cursor within a cursor

extracting records using a cursor within a cursor

From: swoop <carl.barrett_at_newcastle.gov.uk>
Date: 24 May 2005 05:18:50 -0700
Message-ID: <1116937130.380743.127700@g14g2000cwa.googlegroups.com>


I am using Oracle 9i

I need to extract records from a table where certain criteria is met and then compare 4 fields from those records to 4 fields in another table. Where the records don't match I need them extracted into another table.

For example.

I want to select *
>From INVOICE

Where aa = 1, bb = No, cc=2001;

I then want to compare fields test1, test2, test3 and test4 in table INVOICE with fields test1, test2, test3 and test4 in table PAYMENT to see if I get a matching record (This tells me if an invoice has been paid). If these records do not match then I want the record copied from table INVOICE to table NOTPAID.

I understand I need 2 cursors, one to populate variables based on the Invoice table and the other based on the Payment table and then do a comparison on each. Then to Insert the non matching record from Invoice into Notpaid and keep looping until we reach the end of the records in the Invoice cursor.

Any guidance and example code of something similar would be greatly appreciated.

Cheers

Monty Received on Tue May 24 2005 - 07:18:50 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US