How to dynamically change the table name for a update statement

10-11  Source: Network gathering  Views:0 

Hi All,
I need to update a coulumn xyz in either of tables abc and efg based on some condition.
I wrote a cursor which has union of two queries(one querying abc and other efg)
Now based on some inparameter only one will be executed at a time.
And based on some condition a coulumn xyz needs to be updated which is in either of the table.
As the update condition is same
Update abc/efg set xyz=data where condition
I am looking to initialize a variable like v_tname based on some condition and update like
update v_tname .........
(Exactly that may not be like so, But looking a technique like this)
Please help
If there is only two tables you'll need to update then you are better off using static SQL and implementing something like this instead:
        update_condition        BOOLEAN;
        -- initialize update_condition
        update_condition := <some_boolean_check>;
        IF update_condition
                UPDATE abc
                SET    xyz = some_val
                WHERE  some_col = some_other_val;
                UPDATE fgh
                SET    xyz = some_val
                WHERE  some_col = some_other_val;   
        END IF;
/Hope this helps!
Related articles