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 (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 ??
TIBCStoredProced don't work
TIBCStoredProc
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
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
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.
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.
Could you please describe this situation more detailed. We couldn't reproduce it.Ex. 2
...
vA :String;
vA:='2006':
..
IBCConnection.ExecProc('INS_PERIODO',[vA,'010']); don't work corrupt the Table (Incredible for FireBird)