The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Firebird SQL Development
|
Error in trigger while using insert
Discuss Error in trigger while using insert in the Firebird SQL Development forum on Dev Shed. Error in trigger while using insert Firebird SQL Development forum discussing administration, Firebird SQL syntax, or other Firebird SQL-related topics. Firebird is the evolution of Borland's Interbase product.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 10th, 2010, 02:24 AM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 3
Time spent in forums: 36 m 13 sec
Reputation Power: 0
|
|
|
Error in trigger while using insert
Hey there,
I'm new in using firebird, I'm trying to convert adatabase from MSSql to firebird. Now I have a error with a trigger,
SET TERM ^ ;
CREATE TRIGGER "TRIG_TIJDRG_LOGGING_BI" FOR "TIJDRG_LOGGING"
BEFORE INSERT
AS
DECLARE BARCODE VARCHAR(12);
DECLARE ORDERNR NUMERIC;
DECLARE BLADNR NUMERIC(15, 0);
BEGIN
IF(NEW."LOG_ID" IS NULL) THEN NEW."LOG_ID" = GEN_ID("GEN_TIJDRG_LOGGING_LOG_ID",1);
BARCODE=NEW.BARCODE;
IF (NEW.SCANNER <> 0 AND STRLEN(BARCODE)=11) THEN
BEGIN
IF (SUBSTRLEN(BARCODE,1,2) = '10') THEN
BEGIN
For Select ordernr,bladnr From Prodorder Where Paneelnr=(SUBSTRLEN(NEW.BARCODE,1,8) || ',' || SUBSTRLEN(NEW.BARCODE,9,3))
INTO ORDERNR,BLADNR
DO
BEGIN
Insert Into tijdrg_logging_ds (scanner,ordernr,bladnr,datum) VALUES (NEW.SCANNER,:ORDERNR,:BLADNR,NEW.DATUM);
END
END
END
END
^
COMMIT WORK ^
SET TERM ;^
Why is the INSERT INTO command wrong by using the variables :ORDERNR and :BLADNR
|

November 10th, 2010, 04:23 AM
|
|
Contributing User
|
|
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200
  
Time spent in forums: 2 Days 6 h 50 m 14 sec
Reputation Power: 11
|
|
Quote: | Originally Posted by boso2369 Hey there,
I'm new in using firebird, I'm trying to convert adatabase from MSSql to firebird. Now I have a error with a trigger,
Code:
SET TERM ^ ;
CREATE TRIGGER "TRIG_TIJDRG_LOGGING_BI" FOR "TIJDRG_LOGGING"
BEFORE INSERT
AS
DECLARE BARCODE VARCHAR(12);
DECLARE ORDERNR NUMERIC;
DECLARE BLADNR NUMERIC(15, 0);
BEGIN
IF(NEW."LOG_ID" IS NULL) THEN NEW."LOG_ID" = GEN_ID("GEN_TIJDRG_LOGGING_LOG_ID",1);
BARCODE=NEW.BARCODE;
IF (NEW.SCANNER <> 0 AND STRLEN(BARCODE)=11) THEN
BEGIN
IF (SUBSTRLEN(BARCODE,1,2) = '10') THEN
BEGIN
For Select ordernr,bladnr From Prodorder Where Paneelnr=(SUBSTRLEN(NEW.BARCODE,1,8) || ',' || SUBSTRLEN(NEW.BARCODE,9,3))
INTO :ORDERNR,:BLADNR
DO
BEGIN
Insert Into tijdrg_logging_ds (scanner,ordernr,bladnr,datum) VALUES (NEW.SCANNER,:ORDERNR,:BLADNR,NEW.DATUM);
END
END
END
END
^
COMMIT WORK ^
SET TERM ;^
Why is the INSERT INTO command wrong by using the variables :ORDERNR and :BLADNR |
I'm not sure is that an error and is this the solution for your problem but use ':' before the variables when you retun values in them.
What is the exact error message?
|

November 10th, 2010, 04:41 AM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 3
Time spent in forums: 36 m 13 sec
Reputation Power: 0
|
|
|
the error is
Statement #3:
invalid request BLR at offset 789
undefined message number
I'm sure that the :OrderNr in the INsert into command create the error because when I change tis to 0, everything works fine
|

November 11th, 2010, 03:17 AM
|
|
Contributing User
|
|
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200
  
Time spent in forums: 2 Days 6 h 50 m 14 sec
Reputation Power: 11
|
|
Quote: | Originally Posted by boso2369 the error is
Statement #3:
invalid request BLR at offset 789
undefined message number
I'm sure that the :OrderNr in the INsert into command create the error because when I change tis to 0, everything works fine |
Is the data type the same in all tables as the type in the trigger?
|

November 11th, 2010, 07:27 AM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 3
Time spent in forums: 36 m 13 sec
Reputation Power: 0
|
|
|
Yes, I cheked this.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|