Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesnt this work - Interbase Stored Procedure from Delphi

Status
Not open for further replies.

kagee

Programmer
Apr 21, 2004
30
NL
Hi,

I am using Interbase 7.1 and Delphi 7 -- stored procedures have JUST REFUSED to work for me...

! PS ASSIST...

i have created a simple stored procedure (INSERT_DISTRICT) to insert values into a table (districts) and calling the same from delphi code.
In delphi am also using a data module(dmodstocks) where i have dropeed all my components..

If i call the proceure directly from interbase, i cannot see the values inserted into the database, yet the query executes.

INTERBASE STORED PROC CODE:

SET TERM ^;
CREATE PROCEDURE insert_district
(
insDcode varchar(8),insDname varchar(20)
)
AS
BEGIN
INSERT INTO districts
(districtcode, districtname)
VALUES
(
:insDcode,
:insDname
);
END^

SET TERM ; ^

DELPHI CODE:
procedure TFrmDistrict.BtnSaveClick(Sender: TObject);
begin
Dmodstocks.IBSProcDists.Create(self);

with Dmodstocks.IBSProcDists do begin

Dmodstocks.IBSProcDists.Database := Dmodstocks.IBDBStocks;
StoredProcname := 'INSERT_DISTRICT';

Prepare;

Dmodstocks.IBSProcDists.ParamByName('InsDcode').AsString := DistCodetxt.Text;
Dmodstocks.IBSProcDists.Parambyname('InsDname').AsString := DistNametxt.Text;

ExecProc;
Free;

distcodetxt.Clear;
distNameTxt.Clear;
end;

end;
 
If i call the proceure directly from interbase, i cannot see the values inserted into the database, yet the query executes.

I think if you can't see the results when you run it in Interbase that perhaps there's a problem with your SP?

Your Delphi code should be modified a bit:

Code:
procedure TFrmDistrict.BtnSaveClick(Sender: TObject);
begin
  with Dmodstocks.IBSProcDists.Create(self) do 
  begin
    Database := Dmodstocks.IBDBStocks;
    StoredProcname := 'INSERT_DISTRICT';

    Prepare;

    ParamByName('InsDcode').AsString := DistCodetxt.Text;
    Parambyname('InsDname').AsString := DistNametxt.Text;

    ExecProc;
    Free;
  end;
  distcodetxt.Clear;
  distNameTxt.Clear;
end;

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top