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

select into variable values (in cursor loop)

Status
Not open for further replies.

ixnay5

MIS
Jan 10, 2002
68
US
hi all-

what happens to the values contained by myvar in a "select value into myvar" statement executed inside a "foreach x_curs into r_s.*" loop?

here's my code:

foreach d_curs into dat.*

select fssitecd,sotadat into site,sdate
from fssps
where dat.indoc = fssps.sono
and dat.apart = fssps.part
and dat.inlots = fssps.fsserln


insert into tmpall
(indoc,apart,inlots,cpart,serln,fssitecd,sotadat)
values(dat.indoc,dat.apart,dat.inlots,dat.cpart,dat.serln,site,sdate)


end foreach

-------------

suppose i only want to do the insert if i get values for "site" and "sdate"....there are cases when i won't.

so...in each successive pass, will site and sdate retain their values from the prior pass if there query returns nothing in this pass?
 
Hi:

I believe that if "site" and "sdate" don't exist, they'll be set to null. But why chance it? Why don't you:

initialize site, sdate to null

right before the select? Then you can place an if statement before the insert.

Regards,

Ed
 
You should check whether you've received values from the second select:

if sqlca.sqlcode = 100 then
# not found
else
# found
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top