trying to create an UPDATE but am getting and error.
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
update XAPCHECKS
set xapck_amt =
(select sum(apph_paymnts), * from APPHISTF
LEFT JOIN APTRANF on apt_comp = apph_comp and apt_vend = apph_vend and apt_type = apph_type and apt_id = apph_id
LEFT JOIN APBANKF ON apb_code = apt_bank
left join CHMASTF on chm_comp = apb_comp and chm_acct = apb_cash and chm_no = apph_payck
where (apph_comp = '01') and (apph_vend = '1010') and
xapck_check = apph_payck and xapck_chk_type = (CASE chm_type WHEN null THEN ' ' ELSE chm_type END) and xapck_check_status = (CASE chm_stat when null then ' ' ELSE chm_stat END)
and xapck_bank = apt_bank
GROUP by apph_comp, apph_vend, apph_payck, chm_type, chm_stat, apph_paymnts, apph_stat, apph_type, apt_bank, apph_id, apph_paymnts)the problem is here --
set xapck_amt = (select sum(apph_paymnts), *
the error says the subquery has more than one column|||"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated."|||ah, that's because the subquery used in a SET can return only one column, one row
it's called a scalar subquery because it's supposed to return only a single scalar value|||not sure why i had that in there but it seems to working ok.
thanks
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment