Informix: UPDATE with SELECT - syntax? -


i wanna update table persons whoes activity lasted toooo long. update should correct 1 time , subsequent rows need deal new result. thought like

update summary_table st set st.screen_on=newscreenonvalue     st.active_screen_on=st.active_screen_on-(st.screen_on-newscreenonvalue) --old-value minus thedifference (       sub-select rowid, newscreenonvalue ... join ... where....      ) nv (st.rowid=nv.rowid) 

i know can update first , second value directly, rerunning same query. problem costs of subselect seems quite high , therefore wanna avoid double-update resp. double-run of same query.

the above select informal way of writting think get. know st doesn't work, left here better understanding. when try above statement syntaxerror @ position from ends.

this can achieved follows:

update summary_table st set (st.screen_on, st.active_screen_on) =      ((select newscreenonvalue, st.active_screen_on-(st.screen_on-newscreenonvalue)     ...      join...      where..)) [where if additional condition required]; 

the above query works fine on informix tried , tested until make errors in from, join, clauses.

cheers !


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -