Link to home
Start Free TrialLog in
Avatar of Rao_S
Rao_S

asked on

How can i use variables in select statement?

hi, i have to use variables in select statement including a constant value, table name, and where clause, like so..
execute immediate 'INSERT INTO table1 USING SELECT '
                                ||lv_source
                                ||', '
                                ||'col1, col2, col3 FROM '
                                ||lv_tablename
                                ||'WHERE TEMPLATE_NAME LIKE '
                                ||CHR (39)
                                ||lv_likevalue
                                ||CHR (39);
Avatar of Rao_S
Rao_S

ASKER

with the above statement i get a error:
Error: Error in loading:table1-933ORA-00933: SQL command not properly ended
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rao_S

ASKER

thank you sdstuber, it worked!
i have to add another cursor and pass mutiple 'lv_likevalue', let me test that too...
Avatar of Rao_S

ASKER

thank you sdstuber, works correctly!!