TIBCStoredProc problem

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bzwirs
Posts: 40
Joined: Sat 10 Jul 2010 06:47

TIBCStoredProc problem

Post by bzwirs » Thu 14 Apr 2011 03:18

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

tsteinmaurer
Posts: 52
Joined: Thu 17 Dec 2009 08:25

Post by tsteinmaurer » Thu 14 Apr 2011 07:09

Put the Prepare before the various ParamByName calls.

Thomas

AndreyZ

Post by AndreyZ » Thu 14 Apr 2011 07:47

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;

bzwirs
Posts: 40
Joined: Sat 10 Jul 2010 06:47

Post by bzwirs » Fri 15 Apr 2011 00:33

Thanks for that. All works fine now.

Bill

AndreyZ

Post by AndreyZ » Fri 15 Apr 2011 07:07

It is good to see that this problem was solved. If any other questions come up, please contact us.

tsteinmaurer
Posts: 52
Joined: Thu 17 Dec 2009 08:25

Post by tsteinmaurer » Mon 18 Apr 2011 08:24

Is there a difference between PrepareSQL and Prepare?

Thanks,
Thomas

AndreyZ

Post by AndreyZ » Mon 18 Apr 2011 13:38

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.

Post Reply