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!

FOREACH causing -201 SQL Syntax Error

Status
Not open for further replies.

skyleh

MIS
May 19, 2005
5
0
0
US
Please excuse my ignorance. I am learning as I go.

I am updating a program to combine like rows and I created a cusor and then want to loop back through and the rows back to the table after deleting the originals.

My Foreach statment is getting this error. I commented eveything out and added it back one by one to isolate where the error was occuring but I cant see the problem.

declare get_dists2 cursor for
select * into ED2.* , holdZZ.* from hr_earndist, hr_emppay
where exists (select ed.account, ed.gl_key, ed.gl_ledger, ed.gl_obj, ed.jl_key, ed.jl_ledger, ed.jl_obj, ed.lock_flag, ed.misc, ed.over_budg, ed.over_code, sum (ed.percent), ed.prime_flag, min(ed.unique_key),ed.uniqueid
from hr_earndist ed, hr_emppay ep
where ed.uniqueid = ep.uniqueid
and ep.reas_cd = '04'
and b.pay_beg <= targetDATE
and b.pay_end >= targetDATE
group by ed.gl_key, ed.gl_ledger, ed.gl_obj, ed.jl_key, ed.jl_ledger,ed.jl_obj, ed.account, ed.lock_flag, ed.misc, ed.over_budg,ed.over_code, ed.prime_flag, ep.uniqueid)


<deletes>

FOREACH get_dists2
let RECcnt2 = RECcnt2 + 1
let ED2.uniqueid = initEP.uniqueid
if RECcnt2 > 0 and RECcnt2 < 37 and ED2.percent <> 0 then
insert into hr_earndist values (ED2.*)
end if
END FOREACH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top