Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with update

Status
Not open for further replies.

bittmapp

Technical User
Jul 21, 2003
56
0
0
US
I am trying to update a varchar column with a string of SQL as the value and I am getting errors.

for example

update t1
set t1.sqlcolumn = 'INSERT into t2 select case when t3.sqlcolumn in not null then t3.sqlcolumn else 'N/A' end'

The 'N/A' part is where I am gettng the error, am I supposed to use double quotes?

thanks in advance
 
Something like this..........


<eb1>SQL0104N An unexpected token &quot;N&quot; was found following &quot;sqlcolumn IS NOT NULL THEN '&quot;. Expected tokens may include: &quot;<space>&quot;. SQLSTATE=42601

State:42601,Native:-104,Origin:[IBM][CLI Driver][DB2/6000]</eb1>

any ideas / suggestions


Thanks,

 
SET=INSERT into t2

I'm not sure if this will work ...

Did you intend to do

SET=(SELECT case
when t3.sqlcolumn in not null
then t3.sqlcolumn
else 'N/A'
end
from t2
)

Are you sure the select statement will return only one row .. Otherwise, you may have to use the WHERE Clause to filter out the records

Sathyaram


For db2 resoruces visit More DB2 questions answered at
 
What I am trying to do is update the value of sqlcolumn to a SQL statement...... I will then use the value of sqlcolumn in another process.

Thanks for your input

bitt
 
I believe that your query should be like

update t1
set t1.sqlcolumn = 'INSERT into t2 select case when t3.sqlcolumn in not null then t3.sqlcolumn else ''N/A'' end';


Its two consecutive single quotes and not double quotes.

Cheers,
Emmaar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top