Page 1 of 1

TIBCStoredProc problem

Posted: Thu 14 Apr 2011 03:18
by bzwirs
Hi,

Using Delphi 2010, Firebird database, latest version IBDAC.

Have just converted a project from IBX to IBDAC and am having trouble with the IBDAC Stored Procedure component.

There is a procedure in the firebird database that returns the number of sales between two dates. With IBX I had their stored procedure component and called it like this:

function TStockData.Get_ContractSales(FromDate, ToDate: tDate;
SCode: integer): integer;
begin
with V2StoredProc do
begin
StoredProcName := 'GET_CONTRACT_SALES';
ParamByName('START_DATE').asDate := FromDate;
ParamByName('SALE_DATE').asDate := ToDate;
ParamByName('SITE_CODE').asInteger := SCode;
Prepare;
ExecProc;
Result := ParamByName('CONTRACT_SALES').asInteger;
end;
end;

Never had any problems with this using the IBX component and used the same component to call other procedures that are in the database.

Now with IBDAC.....I keep getting this error
...parameter START_DATE not found
.

Probably something simple that I am missing but can someone please tell me what I am doing wrong in relation to the IBDAC component.

regards

Bill

Posted: Thu 14 Apr 2011 07:09
by tsteinmaurer
Put the Prepare before the various ParamByName calls.

Thomas

Posted: Thu 14 Apr 2011 07:47
by AndreyZ
Hello,

To solve the problem you should call the PrepareSQL method in the following way:

Code: Select all

function TStockData.Get_ContractSales(FromDate, ToDate: tDate;
  SCode: integer): integer; 
begin 
  with V2StoredProc do begin 
    StoredProcName := 'GET_CONTRACT_SALES'; 
    PrepareSQL;
    ParamByName('START_DATE').asDate := FromDate; 
    ParamByName('SALE_DATE').asDate := ToDate; 
    ParamByName('SITE_CODE').asInteger := SCode; 
    Prepare; 
    ExecProc; 
    Result := ParamByName('CONTRACT_SALES').asInteger; 
  end;
end;

Posted: Fri 15 Apr 2011 00:33
by bzwirs
Thanks for that. All works fine now.

Bill

Posted: Fri 15 Apr 2011 07:07
by AndreyZ
It is good to see that this problem was solved. If any other questions come up, please contact us.

Posted: Mon 18 Apr 2011 08:24
by tsteinmaurer
Is there a difference between PrepareSQL and Prepare?

Thanks,
Thomas

Posted: Mon 18 Apr 2011 13:38
by AndreyZ
The PrepareSQL method generates SQL statement for a stored procedure executing and describes stored procedure parameters. The Prepare method prepares SQL statements for a stored procedure executing on the server.