473,289 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Embedded SQL returning uncatchable error - Procedure/Trigger

I am getting a frustrating error when i try to insert into the table the trigger i created is on.

Any insight would be appreciated

Error:
Expand|Select|Wrap|Line Numbers
  1. db2 => INSERT INTO trstat VALUES ('340758A',     'POSITION', timestamp ( '2008-08-14-13.53.38.000000' ), '-',             272816, '[0432642N0794126W]No Zone Match',
  2.             'TM4WIN',                    365374, 'ONOAK')
  3. DB21034E  The command was processed as an SQL statement because it was not a
  4. valid Command Line Processor command.  During SQL processing it returned:
  5. SQL0723N  An error occurred in a triggered SQL statement in trigger
  6. "USER.RCC_PTIMEST".  Information returned for the error includes SQLCODE
  7. "-746", SQLSTATE "57053" and message tokens
  8. "USER.RCC_PROC_PTIMESTAMP|SQL08081417151250".  SQLSTATE=09000
  9.  
Code
Expand|Select|Wrap|Line Numbers
  1. --#SET TERMINATOR @ 
  2. DROP TRIGGER rcc_ptimestamp
  3. @
  4. DROP PROCEDURE rcc_proc_ptimestamp
  5. @
  6.  
  7. CREATE PROCEDURE rcc_proc_ptimestamp(
  8.     IN p_code            VARCHAR(10),
  9.     IN p_new_time    TIMESTAMP,
  10.     IN p_trip_num    INTEGER,
  11.     IN p_status        VARCHAR(10)
  12. )
  13.     LANGUAGE SQL
  14.     MODIFIES SQL DATA
  15.  
  16.     P1:BEGIN ATOMIC
  17.  
  18.     DECLARE v_count1 INTEGER DEFAULT 0;
  19.     DECLARE v_count2 INTEGER DEFAULT 0;
  20.     DECLARE    v_old_time    TIMESTAMP;
  21.     DECLARE SQLCODE INTEGER DEFAULT 0;
  22.  
  23.     SELECT count(time_changed) INTO v_count2 FROM trstat WHERE trip_9 = p_trip_num AND code = p_code AND status = 'ENRTE';
  24.     SELECT time_changed INTO v_old_time FROM trstat WHERE trip_9 = p_trip_num AND code = p_code AND status = 'ENRTE';  
  25.  
  26.     IF p_status = 'ENRTE' THEN
  27.         --ENTER INTO rcc_ptimestamp --current En Routed trips
  28.         INSERT INTO rcc_ptimestamp (trip_number, start_time) VALUES (p_trip_num, p_new_time);
  29.     ELSEIF v_count2 <> 0 THEN            
  30.         SELECT count(*) INTO v_count1 FROM rcc_timestamp WHERE trip_number = p_trip_num AND start_time = v_old_time;
  31.  
  32.                 --verify no duplicates in historical table
  33.         IF v_count1 = 0 THEN
  34.             --match
  35.              --INSERT INTO rcc_timestamp
  36.              INSERT INTO rcc_timestamp (trip_number, start_time, end_time, duration) VALUES (p_trip_num, v_old_time, p_new_time, (p_new_time - v_old_time));
  37.              --DELETE FROM rcc_ptimestamp
  38.              DELETE FROM rcc_ptimestamp WHERE trip_number = p_trip_num AND start_time = v_old_time;
  39.         END IF;
  40.     END IF;
  41. END@
  42.  
  43.  
  44. CREATE TRIGGER rcc_ptimestamp AFTER INSERT ON trstat
  45. REFERENCING 
  46.     NEW AS NEW
  47. FOR EACH ROW MODE DB2SQL 
  48.  
  49. BEGIN ATOMIC    
  50.     CALL rcc_proc_ptimestamp(NEW.code, NEW.time_changed, NEW.trip_9, NEW.status);
  51. END@
  52.  
  53. --#SET TERMINATOR ;
  54.  
Aug 14 '08 #1
0 2060

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: seth | last post by:
Last week I encountered an AttributeError in my unit tests that I wasn'table to catch with an "except AttributeError" statement. The problem stemmed from a class that raised an error inside...
4
by: jrefactors | last post by:
I want to distinguish between static SQL, dynamic SQL, and embedded SQL, but couldn't find too much useful resources in the web. For example, if we put SQL statements (SELECT, INSERT, UPDATE,...
0
by: sbest | last post by:
Hi all, I am trying to execute a MS-SQL 2000 stored proedure from PHP 4.2.2 and return the single row of 3 output values. I've whittled down the error messages so that I'm now mainly getting an...
2
by: Paul Reddin | last post by:
Hi, I've implemented calling a SP form a trigger using the CALL_PROCEDURE() UDF from http://www-106.ibm.com/developerworks/db2/library/techarticle/dm-0402greenstein/ A couple of questions...
7
by: ZorpiedoMan | last post by:
Well, I'm still wondering around in the "land of the lost exception"... It seems that controls that are bound to a class and the class throws an error in the SET method of the bound member, the...
1
by: deepdata | last post by:
Hi, I am creating a trigger in DB2 express version. When i use the following syntax to create trigger CREATE TRIGGER USER_PK_TRIGGER BEFORE INSERT On users REFERENCING NEW As N FOR EACH...
3
by: Goog79 | last post by:
Hi everyone, first time here, so I'm sorry if this has been covered already ages ago. :( I am trying to learn T-SQL and Stored Procedures and bought the book on these topics by Djan...
0
by: cngtx | last post by:
Hi, I could not figure out why I am getting the following error when I initiated the Insert into the mainframe DB2 table from a server. I have created the trigger and the stored procedure (as shown...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.