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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update command problem + not valid in the context where used

Status
Not open for further replies.

adev111

Programmer
Jul 8, 2004
44
CA
Hi there all,
I have a table account(acc#,balance...)
a table chequing(acc#,chqbal....)
i the balance attribute of account table is based on chqbal attribute.
say initial balance = 0 for acc# 1
say chqbal = 40
now say i wana update account so i say
update account set balance=balance+chequing.chqbal where acc#=1
here i get an error "CHQBALANCE" is not valid in the context where it is used.
can someone suggest me what am i supposed to do?
Thank You
 
adev111,

does something along the lines of (not syntactically correct) the following help

update account set balance = balance + (select chequing.chqbal from chequing where chequing.acc#=1) where account.acc#=1

What I am trying to say is you haven't told db2 which row you wish to retrieve from for chqbal.

Cheers
Greg
 
hey Greg,
thanks a lot, it helped!
I looked for this in the man pages but couldn't find it, but all is well now
adev111
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top