Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 10th, 2010, 02:24 AM
boso2369 boso2369 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 3 boso2369 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old November 10th, 2010, 04:23 AM
mIRCata mIRCata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200 mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 6 h 51 m 58 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?

Reply With Quote
  #3  
Old November 10th, 2010, 04:41 AM
boso2369 boso2369 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 3 boso2369 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old November 11th, 2010, 03:17 AM
mIRCata mIRCata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200 mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 6 h 51 m 58 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?

Reply With Quote
  #5  
Old November 11th, 2010, 07:27 AM
boso2369 boso2369 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 3 boso2369 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 13 sec
Reputation Power: 0
Yes, I cheked this.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Error in trigger while using insert

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap