Subject | insertSQL Help please |
---|---|
Author | newgen3152003 |
Post date | 2004-03-08T17:29:28Z |
Hi all,
I have a problem with insertSql, it seems to be generating 2 inserts
when the dbnavigator's insert is clicked. I am getting the generator
count by 2 which I am assuming is because of the 2 inserts. can one
of you gurus tell me what is wrong with my code?
Maybe I'm not using InsertSQL property correctly? If I do not execute
insert in the "LocatInsert" procedure I do not have my form in insert
mode. if I ignore the custom click and use the insert I get the same
problem;
Can somebody advise me please
Daniel
procedure TLocatT.NavLocationsCustomClick(Sender: TObject;
Button: TJfDbNavigatorButton; var Handled: Boolean);
begin
handled := true;
if Button = dnbInsert then
LocatInsert;
procedure TLocatT.LocatInsert;
begin
with DataM.AllLoc do
begin
ReadOnly := False;
InsertSQL.Text := ' ';
InsertSQL.Append('execute procedure NewLocation');
InsertSQL.Append
('(:LOCCODE, :LOCNAME, :LOCTYPE , :ADD1, :ADD2, :CITY,');
InsertSQL.Append
(':PROV, :ZIP , :PHONE, :FAX , :AUX, :CONTACT, :EMAIL , :COMMENTS , :N
OTE );');
open;
insert;
end;
LocatF := nil;
JFWndCreateModal(Self,LocatF,TLocatF,ceoPriorWindow);
LocatF.jfcform1.caption := 'Location Form';
LocatF.showmodal;
end;
stored procedure/ trigger code;
create procedure NewLocation(
LOCCODE VARCHAR( 8 )
, LOCNAME VARCHAR( 35 )
, LOCTYPE VARCHAR( 25 )
, ADD1 VARCHAR( 35 )
, ADD2 VARCHAR( 35 )
, CITY VARCHAR( 25 )
, PROV VARCHAR( 8 )
, ZIP VARCHAR( 10 )
, PHONE VARCHAR( 15 )
, FAX VARCHAR( 15 )
, AUX VARCHAR( 15 )
, CONTACT VARCHAR( 35 )
, EMAIL VARCHAR( 35 )
, COMMENTS VARCHAR( 50 )
, NOTE BLOB( 65535, 0 )
)
as
begin
insert into LOCATIONS
(LOCCODE,LOCNAME,LOCTYPE ,ADD1,ADD2,CITY,PROV, ZIP , PHONE, FAX ,
AUX, CONTACT, EMAIL , COMMENTS , NOTE )
values
(:LOCCODE, :LOCNAME, :LOCTYPE , :ADD1, :ADD2, :CITY, :PROV, :ZIP , :PH
ONE, :FAX , :AUX, :CONTACT, :EMAIL , :COMMENTS , :NOTE );
suspend;
end^
/* Generators to AutoInc fields for table "LOCATIONS" */
CREATE GENERATOR GEN_LOCATIONS_IDLOC;
SET GENERATOR GEN_LOCATIONS_IDLOC TO 200;
SET TERM ^;
CREATE TRIGGER TRIG_LOCATIONS_BI FOR LOCATIONS BEFORE INSERT
AS BEGIN
IF(NEW.IDLOC IS NULL) THEN NEW.IDLOC = GEN_ID
(GEN_LOCATIONS_IDLOC,1);
END ^
SET TERM ;^
I have a problem with insertSql, it seems to be generating 2 inserts
when the dbnavigator's insert is clicked. I am getting the generator
count by 2 which I am assuming is because of the 2 inserts. can one
of you gurus tell me what is wrong with my code?
Maybe I'm not using InsertSQL property correctly? If I do not execute
insert in the "LocatInsert" procedure I do not have my form in insert
mode. if I ignore the custom click and use the insert I get the same
problem;
Can somebody advise me please
Daniel
procedure TLocatT.NavLocationsCustomClick(Sender: TObject;
Button: TJfDbNavigatorButton; var Handled: Boolean);
begin
handled := true;
if Button = dnbInsert then
LocatInsert;
procedure TLocatT.LocatInsert;
begin
with DataM.AllLoc do
begin
ReadOnly := False;
InsertSQL.Text := ' ';
InsertSQL.Append('execute procedure NewLocation');
InsertSQL.Append
('(:LOCCODE, :LOCNAME, :LOCTYPE , :ADD1, :ADD2, :CITY,');
InsertSQL.Append
(':PROV, :ZIP , :PHONE, :FAX , :AUX, :CONTACT, :EMAIL , :COMMENTS , :N
OTE );');
open;
insert;
end;
LocatF := nil;
JFWndCreateModal(Self,LocatF,TLocatF,ceoPriorWindow);
LocatF.jfcform1.caption := 'Location Form';
LocatF.showmodal;
end;
stored procedure/ trigger code;
create procedure NewLocation(
LOCCODE VARCHAR( 8 )
, LOCNAME VARCHAR( 35 )
, LOCTYPE VARCHAR( 25 )
, ADD1 VARCHAR( 35 )
, ADD2 VARCHAR( 35 )
, CITY VARCHAR( 25 )
, PROV VARCHAR( 8 )
, ZIP VARCHAR( 10 )
, PHONE VARCHAR( 15 )
, FAX VARCHAR( 15 )
, AUX VARCHAR( 15 )
, CONTACT VARCHAR( 35 )
, EMAIL VARCHAR( 35 )
, COMMENTS VARCHAR( 50 )
, NOTE BLOB( 65535, 0 )
)
as
begin
insert into LOCATIONS
(LOCCODE,LOCNAME,LOCTYPE ,ADD1,ADD2,CITY,PROV, ZIP , PHONE, FAX ,
AUX, CONTACT, EMAIL , COMMENTS , NOTE )
values
(:LOCCODE, :LOCNAME, :LOCTYPE , :ADD1, :ADD2, :CITY, :PROV, :ZIP , :PH
ONE, :FAX , :AUX, :CONTACT, :EMAIL , :COMMENTS , :NOTE );
suspend;
end^
/* Generators to AutoInc fields for table "LOCATIONS" */
CREATE GENERATOR GEN_LOCATIONS_IDLOC;
SET GENERATOR GEN_LOCATIONS_IDLOC TO 200;
SET TERM ^;
CREATE TRIGGER TRIG_LOCATIONS_BI FOR LOCATIONS BEFORE INSERT
AS BEGIN
IF(NEW.IDLOC IS NULL) THEN NEW.IDLOC = GEN_ID
(GEN_LOCATIONS_IDLOC,1);
END ^
SET TERM ;^