Re: function in foreach loop
Posted in 2004
Randy,
This syntax works:
===============
CREATE FUNCTION AllocatePayment(cType CHAR(1), cID SMALLINT, cCat
CHAR(2),
cNum INT)
RETURNING char(2) ,char(10) ;DEFINE temptext char(10);
DEFINE rectype char(2);
DEFINE allocpercent decimal(10,9);
LET temptext = 'Hello';
FOREACH
execute function AmountBasedAllocation(cType,cID,cCat,cNum) into
rectype, allocpercent
RETURN rectype,allocpercent with resume; END FOREACH;
END FUNCTION;
============
When you write a stored procedure in Server Studio JE, you can
actually use SPL helper feature (popup Paste SPL menu in SQL Editor)
It provides syntax templates for all SPL statements.
"Kennedy, Randy" <RKennedy@scottsdaleaz.gov> wrote in message news:<ckguso$kkr$1@news.xmission.com>...
> 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 = 'Hello';
>
> FOREACH
> CALL AmountBasedAllocation(cType,cID,cCat,cNum) returning
> rectype,allocpercent;
> RETURN rectype,temptext with resume;
> END FOREACH;
> END FUNCTION;
>
> Thanks,
> Randy
>
>