RE: function in foreach loop
Posted in 2004
Sorry Randy,
I forgot about the FOREACH even though I cut and pasted it. Duhhh.
FOREACH
EXECUTE PROCEDURE AmountBasedAllocation(cType,cID,cCat,cNum) INTO
rectype,allocpercent -- Note no semicolon.
RETURN rectype,temptext with resume; END FOREACH;
END FUNCTION;
-----Original Message-----
From: Kennedy, Randy [mailto:RKennedy@scottsdaleaz.gov]=20
Sent: Monday, October 11, 2004 9:59 AM
To: Link, David A.; informix-list@iiug.org
Subject: RE: function in foreach loop
I have received this format from 2 people and tried it, but still get a
-201
syntax error. I use server studio and it moves the cursor to the 'A' in
the
function being called after reporting the syntax error. Here is the
exact
code I am using now (temptext return is just to test this style
function, I
will be doing much more once I get the foreach to work)
(AmountBasedAllocation returns a char(2) and decimal(10,9) and works
fine):
CREATE FUNCTION AllocatePayment(cType CHAR(1), cID SMALLINT, cCat
CHAR(2),
cNum INT)
RETURNING char(2) as rectype,char(10) as tmptext;DEFINE temptext char(10);
DEFINE rectype char(2);
DEFINE allocpercent decimal(10,9);
LET temptext =3D 'Hello';
FOREACH
CALL AmountBasedAllocation(cType,cID,cCat,cNum) returning
rectype,allocpercent;
RETURN rectype,temptext with resume;
END FOREACH;
END FUNCTION;
Thanks,
Randy
-----Original Message-----
From: Link, David A. [mailto:DALink@west.com]
Sent: Monday, October 11, 2004 7:33 AM
To: Kennedy, Randy; informix-list@iiug.org
Subject: RE: function in foreach loop
I believe you need to call your function the following way:
FOREACH
Call function(parameters) returning x,y;
do some more stuff
return y,z
END FOREACH
-----Original Message-----
From: owner-informix-list@iiug.org [mailto:owner-informix-list@iiug.org]
On Behalf Of Kennedy, Randy
Sent: Monday, October 11, 2004 9:20 AM
To: informix-list@iiug.org
Subject: function in foreach loop
I have a function that uses a return with resume to return 2 columns and
usually between 2 and 7 rows. I now want to use this function in a
foreach
loop in another function to use each returned value in additional
processes.
I keep getting syntax errors with the following style code:
FOREACH
Let x,y =3D function(parameters);
do some more stuff
return y,z
END FOREACH
x,y, and z have all been defined.
Is this supported? IDS 9.4FC3 on HPUX11i
TIA,
Randy
sending to informix-list
sending to informix-list