Subject RE: [firebird-support] Re: Newbie: SP isc_dsql_prepare failed
Author Svein Erling Tysvær
Don't know which Firebird version you are using, but try

SELECT NarrAcctOpBal2.lmNarration, mAccounts.cCity
FROM mAccounts
LEFT JOIN NarrAcctOpBal2(mAccounts.iID) on NarrAcctOpBal2.liID = mAccounts.iID

Firebird 1.5 or earlier (I don't know about Fb 2.0) may put NarrAcctOpBal2 first in the plan, which will of course fail, hence the need to use LEFT JOIN.

HTH,
Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Bhavbhuti Nathwani
Sent: 22. november 2007 15:23
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Re: Newbie: SP isc_dsql_prepare failed

Thanks again Helen and Alan for both of you pointing me in the right
direction. Though for this SP I have not been able to use it in the
SELECT statement like below:

SELECT NarrAcctOpBal2.lmNarration, mAccounts.cCity
FROM mAccounts
JOIN NarrAcctOpBal2(mAccounts.iID) on NarrAcctOpBal2.liID =
mAccounts.iID

How can I send the mAccounts.iID, let SP do the processing (not much
yet) and return lmNarration for each liID that matches with iID of
mAccounts (see my untested modified SP below), so I get a result set like,

Opening Balance of A.B.C. Ltd. A/c., Amsterdam
Opening Balance of D.E.F. LLC A/c., London
Opening Balance of X.Y.Z. Co. A/c., New York

Thanks again and regards
Bhavbhuti


CREATE PROCEDURE NARRACCTOPBAL2 (
IID Integer )
RETURNS (
LIID Integer,
LMNARRATION Varchar(16) ) /* !!!!!!!!! */
AS
BEGIN
FOR
SELECT mAccounts.iID, 'Opening Balance of ' || mAccouts.cName
FROM MACCOUNTS
where maccounts.iID = :iID
INTO :liid, :lmnarration
DO
SUSPEND;
END