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