I am using the following code in a PL SQL procedure:
execute immediate 'select count(distinct item_type) into counter_variable
from items where ' || field_name || ' is not null'
Here,
counter_variable is declared in the declaration section of the procedure field_name is the IN parameter to the PL SQL procedure and the values passed will be column names from the 'items' table
The error that I get is 'Invalid SQL Statement' and I am not able to figure out the reason. Any ideas?
Thanks
The into
clause is PL/SQL and not valid in an SQL statement.
Try this:
execute immediate 'select count(distinct item_type)
from items where ' || field_name || ' is not null' into counter_variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With