Re: FOREACH problem in SPL
Posted in 2006
Jonathan Leffler wrote:
> Gil Lapid wrote:
>
>> I'm very new to informix and I try to write simple test procedure that
>> return multi rows value to the caller. I tried:
>>
>> create function func1(c1 varchar(255)) returning person_t2;>> define ret person_t2;
>> FOREACH cur1 FOR
>> SELECT c2 into ret FROM foo7;
>> return ret WITH RESUME;
>> END FOREACH
>> end function
>>
>> but it fails with syntax error that I was not able to figure out
>> myself(table foo7 and type person_t2 exists and having the correct
>> types - c2 column is from type person_t2 ).
>>
>> The problem happend only when I have the FOREACH loop. Otherwise it
>> works.
>
> Semi-colons in SPL are an endless source of frustration.
>
> I think you need one after END FOREACH and you don't need one after
> FROM foo7, but I'd have to run the stuff through the server to be sure.
Also, your "FOREACH cur1 FOR" makes it an update cursor: each row selected is
locked. You probably don't need or want this, so just use "FOREACH" instead.
--
Regards,
Doug Lawry
www.douglawry.webhop.org