Beam
asked on
PL/SQL procedure to compare rows in two tables
Hello there,
I need to write a procedure to compare the results in two tables. Lets call them table1 and table 2.
The field I am trying to compare is called prod_id with holds integer.
For everytime the value in 'prod_id' in table 1 matches a value in 'prod_id' in table 2, I want to set another field in table 1 called 'match (boolean) to true elseif no match false.
So for example:
Table 1 Table 2
prod_id match prod_id
1 FALSE 3
2 FALSE 7
3 TRUE 8
4 FALSE 9
I guess I need two cursors and then run some sort of loop to compare the first row of Table 1 to every row of Table 2. Then the second row of Table 1 to every row of Table 2 and so on ?
Please could someone outline a procedure as this is driving me mad.
Thanks
Ren
I need to write a procedure to compare the results in two tables. Lets call them table1 and table 2.
The field I am trying to compare is called prod_id with holds integer.
For everytime the value in 'prod_id' in table 1 matches a value in 'prod_id' in table 2, I want to set another field in table 1 called 'match (boolean) to true elseif no match false.
So for example:
Table 1 Table 2
prod_id match prod_id
1 FALSE 3
2 FALSE 7
3 TRUE 8
4 FALSE 9
I guess I need two cursors and then run some sort of loop to compare the first row of Table 1 to every row of Table 2. Then the second row of Table 1 to every row of Table 2 and so on ?
Please could someone outline a procedure as this is driving me mad.
Thanks
Ren
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thats is just what I was looking for.
Thanks again