TIBCStoredProced don't work

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brefp
Posts: 2
Joined: Thu 11 Nov 2004 09:20

TIBCStoredProced don't work

Post by brefp » Mon 29 Jan 2007 20:43

Firebird 2.0

Ex. 1

IBCConnection.ExecProc('INS_PERIODO',['2006','010']); is OK

Ex. 2
...
vA :String;
vA:='2006':
..
IBCConnection.ExecProc('INS_PERIODO',[vA,'010']); don't work corrupt the Table :shock: (Incredible for FireBird)

Ex. 3

with DM.InsPeriodo do
begin
DM.InsPeriodo.ParamByName('IANNO').AsString:='AA';
DM.InsPeriodo.ParamByName('IMESE').AsString:='MM';
DM.InsPeriodo.Execute
end

don't work

THY

NB.

I must continue to use IBO ??

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Tue 30 Jan 2007 13:39

We can't reproduce this problem.

Please specify the 'INS_PERIODO' DDL SQL text, also specify DM.InsPeriodo object ClassType and its settings.

If it is possible, send us a complete small demo project, that demonstrates this problem with scripts to create server side objects.

brefp
Posts: 2
Joined: Thu 11 Nov 2004 09:20

TIBCStoredProc

Post by brefp » Wed 31 Jan 2007 11:59

Examples:

Button1Click is OK

Button1Click don't Work


thank you


Code:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, MemDS, DBAccess, IBC;

type
TForm1 = class(TForm)
IBCConnection1: TIBCConnection;
IBCStoredProc1: TIBCStoredProc;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

//Is OK
procedure TForm1.Button1Click(Sender: TObject);
var
A, B :String;
begin
A:='1234567890ABCDE';
B:='TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST';
//
IBCConnection1.ExecProc('INS_TBL_TEST',[A,B]);
end;

//Don't Work !
procedure TForm1.Button2Click(Sender: TObject);
var
A, B :String;
begin
A:='ABCDE1234567890';
B:='TEST2TEST2TEST2TEST2TEST2TEST2TEST2TEST2TEST2TEST2TEST';
//
IBCStoredProc1.Prepare;
IBCStoredProc1.ParamByName('IFIELD1').AsString:=A;
IBCStoredProc1.ParamByName('IFIELD2').AsString:=B;
IBCStoredProc1.ExecProc;

end;

end.


/////////////////////////////DATABASE///////////////////////////////////////


CREATE GENERATOR TEST_GENERATOR;
SET GENERATOR TEST_GENERATOR TO 0;


CREATE TABLE TBL_TEST (
ID INTEGER NOT NULL,
FIELD1 VARCHAR(10),
FIELD2 VARCHAR(50)
);

ALTER TABLE TBL_TEST ADD CONSTRAINT PK_TBL_TEST PRIMARY KEY (ID);

CREATE PROCEDURE INS_TBL_TEST (
IFIELD1 VARCHAR(10),
IFIELD2 VARCHAR(50))
AS
declare variable gen_val integer;
begin
GEN_VAL = GEN_ID( test_generator , 1 );
INSERT INTO tbl_test (tbl_test.id, tbl_test.field1, tbl_test.field2)
Values(:GEN_VAL, upper(:IFIELD1),upper(:IFIELD2));
suspend;
end

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Thu 01 Feb 2007 10:25

I suppose that the reason of this issue is value of the TIBCStoredProc.AutoCommit property.
All InterBase/Firebird database operations are performed in transaction context, so to make changes visible to another transactions (users sessions) - it is required to commit the current transaction.
In your case this can be done by setting TIBCStoredProc.AutoCommit to True or by explicit call to TIBCStoredProc.Transaction.Commit (CommitRetainig).
Note that when you call TIBCConnection.ExecProc, this routine is executed with TIBCConnection.AutoCommit settings - so this was what confuses you.
Ex. 2
...
vA :String;
vA:='2006':
..
IBCConnection.ExecProc('INS_PERIODO',[vA,'010']); don't work corrupt the Table (Incredible for FireBird)
Could you please describe this situation more detailed. We couldn't reproduce it.

Post Reply