Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DYNAMIC SQL -- to compare column names given by VARRAY

541007Sep 27 2012 — edited Oct 19 2012
Hi

I have a procedure to which I am getting 2 rows from the same table as in parameters.

Within the procedure I have a VARRAY holding specific column names of the same table as strings. This collection is defined in another package as I want that list to be globally available right across the instance.

The requirement is that I want to compare only the columns of the 2 rows available in the collection. If any are different then I need to do something.
PROCEDURE upd (ip_old test_table%ROWTYPE
              ,ip_new test_table%ROWTYPE) IS

lr_column_list global_pkg.column_match := global_pkg.SERVICE_EVENTS_LIST; -- this declares and initializes a varray lr_column_list with a list of column names
lr_update_required BOOLEAN := FALSE;
  
BEGIN
   
    FOR i IN 1..lr_column_list.COUNT LOOP
 		-- I need to iterate through this and compare the values of similarly named columns between the old and new rows
		-- and if matching make lr_update_require := TRUE
    END LOOP;  
    
    IF lr_update_required = TRUE THEN
       -- DO SOMETHING
    END IF


END upd;
Any ideas how I can do this comparison? I have been dynamic sql land and back with no luck!

Thanks very much for your expertise.

Edited by: Fouwaaz on Sep 28, 2012 9:42 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2012
Added on Sep 27 2012
11 comments
1,443 views