Page 1 of 1

How to update a table there is a expression in the sql

Posted: Wed Feb 08, 2012 3:40 am
by dongyingying
when I want to update a column and set the column_a = column_a * percent in a table in a stage, also in the input link there are two columns and named to key_1 and percent.

so the sql i want to write to like :

update table_name set column_a = column_a * percent where key_1=? ;

but when i run the job there is a error :
Task_one_point_two..Employee: [IBM][CLI Driver][DB2/AIX64] SQL0206N "percent" is not valid in the context where it is used. SQLSTATE=42703

who can help me out thanks.

Re: How to update a table there is a expression in the sql

Posted: Wed Feb 08, 2012 5:42 am
by HendrikB
Which DB stage do you use for custom sql?

In case of using the DB2 Connector for example try this ...

update table_name set column_a = column_a * orchestrate.percent where key_1=orchestrate.key_1 ;

'orchestrate' means taking the column value out of the ETL flow at runtime

Posted: Thu Feb 09, 2012 2:18 am
by dongyingying
HendrikB,

yes, u r right ,when i check it ,I found the sql can't be write to Column_a =Column_a*(1+percent), The bracket can not be accept in the sql.