Hello Guys, 

I have the following problem and I solved it in the following way, I need to 
see if there are a better approaches to do that. any suggestion is welcome 


The problem 


I have function have this logic  



FOR record1 in SELECT .... LOOP

     FRO record2 in SELECT ... LOOP
     

         -- Here the  function business logic changes based on a lookup table;  
for example, the  there are many logical conditions AND and OR  and the 
decision of how to combine these logical conditions may change based on the 
lookup table 

        -- i.e in some cases the logical condition might be  ' if record1. 
attribute1 = record2. attribute1 OR ....' or it may be  ' if record1. 
attribute1 = record2. attribute1 AND....'
         -- The number of attributes is very large (around 45) which means I 
have endless combination of these logical conditions  and also the lookup 
tables can be changed   
            

    END LOOP 
END LOOP

So my solution was 

to create atrriger on the  lookup table to create this function 


DECLARE 
    function_body TEXT := 'CREATE OR REPLACE .... '
    ..
BEGIN
    ...
    FOR RECORD  in the lookup table .....
        function_body = function_body 


EXECUTE function_body 
   ..

Regards

Reply via email to