Subject RE: [firebird-support] Newbie: SP isc_dsql_prepare failed
Author Alan McDonald
> Hi all
>
> I have another SP gearing towards what I intend to return
> from SP. I want to use it in a SELECT as follows:
>
> SELECT mAccounts.*, NarrAcctOpBal2.mNarration
> FROM mAccounts
> JOIN NARRACCTOPBAL2(mAccounts.iID) on
> NarrAcctOpBal2.iID = mAccounts.Iid

I have a personal aversion to this (mAccounts.*, ) syntax. You are always
better to name all fields explicitly.
The join here to the SP will not provide good performance I'm afraid. Try it
and see if you're happy. (see below for changed SP). I'd probably set this
up with a view instead of an SP so the join works well.
Alan

>
> My SP which errors and cannot be created is as follows:
> SET TERM ^ ;
> CREATE PROCEDURE NARRACCTOPBAL2 (
> IID Integer )
> RETURNS (
> LIID Integer,
> LMNARRATION Varchar(32000) )
> AS
> BEGIN
FOR SELECT mAccounts.iID , 'Opening Balance' FROM MACCOUNTS
where maccounts.iID = :iID into :LIID, LMNARRATION DO BEGIN
SUSPEND;
END;

> END^
> SET TERM ; ^
>
> Please advise and thanks for bearing with my newbie queries.
>
> Regards
> Bhavbhuti