Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3193

Re: syntax error for dynamic column for update query

$
0
0

Consider them as strings and try to concatenate them. In your last statement, the SQL you want to execute is :

 

SELECT 'UMESH' FROM DUMMY;

So while framing the dynamic sql, you need to frame that string like below:

 

  execute immediate 'select '''||:var_name||''' from dummy;';

We have totally 3 parts of the string and we need to have 'UMESH' ( with quotes) also as part of the string:

 

'select ' -- first part of the string

'' --  (to escape the quotes to get one quote )

:var_name -- concatenating the Variable

'' --  (to escape the quotes to get one quote )

' from dummy;' -- Last part of the string

 

So the procedure must be like this:

 

create procedure USP_TEST()
as
begin  declare var_name varchar(10) := 'UMESH';  execute immediate 'select '''||:var_name||''' from dummy;';
end

Hope this helps

 

Regards,

Krishna Tangudu


Viewing all articles
Browse latest Browse all 3193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>