I have a problem creating an sql query -
I have to replace each appearance of a hard-coded function variable with an expression from another table. The problem is that there might be several expressions to replace in one field, for ex :
Here is a sample of dynamic SQL within a PL/SQL block. It shows how to replace hard coded table named with a variable. You can modify to include column names and other things.
cursor c1 IS SELECT TABLE_NAME FROM USER_TABLES.
FETCH c1 INTO v_tab;
v_sql := 'SELECT id FROM ' || v_tab;
EXECUTE IMMEDIATE (v_sql) INTO (v_id);
I am really sorry for my ignorance, but I don't know PL/SQL, If you could explain your SQL, it would be great,
My Table name is "TBPCRULES" and the field that holds the hard coded function called "EXPRESSION",
I want to replace all of the "xxx" expressions (only the ones that are followed by "ByName" string) with a different field called "CID" from the table - "TBNAMES", can you try to modify your sample please ?