How can I pass a column name as a parameter to a SQL statement ?
I have a table with columns named Log1,Log2,...,Log10.
I want to run a loop and for each cicle to update the alue in LogX column.
This is my code :
for i IN 1..11 LOOP
logX := CONCAT('Log',TO_CHAR(i,'99'));
UPDATE myTable set &logX='010100000000000';
"logX" is the varaible that contais the current column name.
You would typically not want to use :myval the way I have.
You'd want to use it as a bind variable in the execute immediate command so that your SQL is reusable. I left that out for clarity. I'm also going to update just the first row in this example.