473,394 Members | 1,703 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,394 software developers and data experts.

DB2 Nested Stored Procedures and labeled_begin_atomic error

2
In DB2 UDB, I call a stored procedure, which in turn calls a number of other stored procedures. I am used Command Editor.

Here is the call which fails and the error message:
call arc.arc_restore;
------------------------------------------------------------------------------
call arc.arc_restore
SQL0104N An unexpected token "CALL ARC.ARC_DISABLE_TRIG('MAXIMO','WORKLOG_T"
was found following " ". Expected tokens may include:
"<labeled_begin_atomic>". SQLSTATE=42601


Explanation:

A syntax error in the SQL statement or the input command string for the SYSPROC.ADMIN_CMD procedure was detected at the specified token following the text "<text>". The "<text>" field indicates the 20 characters of the SQL statement or the input command string for the SYSPROC.ADMIN_CMD procedure that preceded the token that is not valid.


Can someone explain what that means and how to fix it? Thanks in advance.

Here is the stored procedure called:

Expand|Select|Wrap|Line Numbers
  1. CONNECT RESET
  2. $
  3. CONNECT TO MAXDB71
  4.  
  5. $
  6. DROP PROCEDURE ARC.ARC_RESTORE
  7. $
  8.  
  9. CREATE PROCEDURE ARC.ARC_RESTORE ()
  10. LANGUAGE SQL
  11. BEGIN ATOMIC
  12. DECLARE stmt varchar(32000) default ' ';
  13.  
  14. --Turn off all trigs on the tables being inserted in
  15. --quiesce database immediate
  16. set stmt = '
  17. CALL ARC.arc_disable_trig(''MAXIMO'',''WORKLOG_T'');
  18. CALL ARC.arc_disable_trig(''MAXIMO'',''WORKLOG_U'');
  19. CALL ARC.arc_disable_trig(''MAXIMO'',''LONGDESCRIPTION_T'');
  20. CALL ARC.arc_disable_trig(''MAXIMO'',''LONGDESCRIPTION_U'');
  21. CALL ARC.arc_disable_trig(''MAXIMO'',''COMMLOG_T'');
  22. CALL ARC.arc_disable_trig(''MAXIMO'',''COMMLOG_U'');
  23. CALL ARC.arc_disable_trig(''MAXIMO'',''PLUSPTKPRICETOT_T'');
  24. CALL ARC.arc_disable_trig(''MAXIMO'',''PLUSPTKPRICETOT_U'');
  25. CALL ARC.arc_disable_trig(''MAXIMO'',''PERSISTSTATUS_T'');
  26. CALL ARC.arc_disable_trig(''MAXIMO'',''PERSISTSTATUS_U'');
  27. CALL ARC.arc_disable_trig(''MAXIMO'',''WORKVIEW_T'');
  28. CALL ARC.arc_disable_trig(''MAXIMO'',''WORKVIEW_U'');
  29. CALL ARC.arc_disable_trig(''MAXIMO'',''TKSTATUS_T'');
  30. CALL ARC.arc_disable_trig(''MAXIMO'',''TKSTATUS_U'');
  31. CALL ARC.arc_disable_trig(''MAXIMO'',''TICKET_T'');
  32. CALL ARC.arc_disable_trig(''MAXIMO'',''TICKET_U'');
  33.  
  34. -- Call your routines here
  35.  
  36. CALL ARC.arc_enable_trig(''MAXIMO'',''WORKLOG_T'');
  37. CALL ARC.arc_enable_trig(''MAXIMO'',''WORKLOG_U'');
  38. CALL ARC.arc_enable_trig(''MAXIMO'',''LONGDESCRIPTION_T'');
  39. CALL ARC.arc_enable_trig(''MAXIMO'',''LONGDESCRIPTION_U'');
  40. CALL ARC.arc_enable_trig(''MAXIMO'',''COMMLOG_T'');
  41. CALL ARC.arc_enable_trig(''MAXIMO'',''COMMLOG_U'');
  42. CALL ARC.arc_enable_trig(''MAXIMO'',''PLUSPTKPRICETOTALS_T'');
  43. CALL ARC.arc_enable_trig(''MAXIMO'',''PLUSPTKPRICETOTALS_U'');
  44. CALL ARC.arc_enable_trig(''MAXIMO'',''PERSISTSTATUS_T'');
  45. CALL ARC.arc_enable_trig(''MAXIMO'',''PERSISTSTATUS_U'');
  46. CALL ARC.arc_enable_trig(''MAXIMO'',''WORKVIEW_T'');
  47. CALL ARC.arc_enable_trig(''MAXIMO'',''WORKVIEW_U'');
  48. CALL ARC.arc_enable_trig(''MAXIMO'',''TKSTATUS_T'');
  49. CALL ARC.arc_enable_trig(''MAXIMO'',''TKSTATUS_U'');
  50. CALL ARC.arc_enable_trig(''MAXIMO'',''TICKET_T'');
  51. CALL ARC.arc_enable_trig(''MAXIMO'',''TICKET_U'');
  52. ';
  53. execute immediate stmt;
  54.  
  55. --unquiesce db
  56.  
  57. END
  58. $
  59.  
And here are the stored procedures it calls. These work when I call them directly from the command processor.

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE ARC.ARC_ENABLE_TRIG ( 
  2.           IN v_schema VARCHAR(128),  
  3.            IN v_name VARCHAR(128)) 
  4. LANGUAGE SQL 
  5. BEGIN 
  6. DECLARE SQLCODE INT DEFAULT 0; 
  7. DECLARE v_qualifier VARCHAR(128); 
  8. DECLARE v_func_path VARCHAR(1000); 
  9. DECLARE v_stmt VARCHAR(32672);
  10. DECLARE v_stmt2 VARCHAR(32672); 
  11. DECLARE v_curr_qualifier VARCHAR(128); 
  12. DECLARE v_curr_funcpath VARCHAR(1000); 
  13. DECLARE v_owner VARCHAR(128);
  14. DECLARE EXIT HANDLER FOR SQLWARNING 
  15.            SIGNAL SQLSTATE '80000'  
  16. SET MESSAGE_TEXT = 'Error. TRIG manual recreation required'; 
  17. SET v_curr_qualifier = CURRENT SCHEMA; 
  18. SET v_curr_funcpath = CURRENT FUNCTION PATH; 
  19.  
  20. SELECT qualifier, func_path, TEXT, owner into v_qualifier, v_func_path, v_stmt, v_owner
  21. FROM ARC.ARC_DISABLED_TRIGS 
  22.           WHERE trigschema=v_schema and trigname=v_name;
  23.  
  24. SET v_func_path = 'SET CURRENT FUNCTION PATH = ' || v_func_path; 
  25. EXECUTE IMMEDIATE v_func_path; 
  26.  
  27. SET v_qualifier = 'SET CURRENT SCHEMA = ' || v_qualifier; 
  28. EXECUTE IMMEDIATE v_qualifier; 
  29.  
  30. EXECUTE IMMEDIATE v_stmt;
  31.  
  32. SET v_stmt2 = 'TRANSFER OWNERSHIP OF TRIG ' || v_schema || '.' || v_name || ' to USER ' || v_owner ||' 
  33.  
  34. PRESERVE PRIVILEGES';
  35.  
  36. EXECUTE IMMEDIATE v_stmt2;
  37.  
  38. DELETE FROM ARC.ARC_DISABLED_TRIGS 
  39.           WHERE trigschema=v_schema and trigname=v_name; 
  40.  
  41. SET v_curr_qualifier = 'SET SCHEMA = ' || v_curr_qualifier; 
  42. SET v_curr_funcpath = 'SET CURRENT FUNCTION PATH = ' || v_curr_funcpath; 
  43. EXECUTE IMMEDIATE v_curr_qualifier; 
  44. EXECUTE IMMEDIATE v_curr_funcpath; 
  45. END
  46. $
  47.  
  48. CREATE PROCEDURE ARC.ARC_DISABLE_TRIG ( 
  49.            IN v_schema VARCHAR(128),  
  50.            IN v_name VARCHAR(128)) 
  51. SPECIFIC ARC_DISABLE_TRIG 
  52. LANGUAGE SQL 
  53. BEGIN 
  54. DECLARE SQLCODE INT DEFAULT 0; 
  55. DECLARE v_stmt VARCHAR(250);  
  56. DECLARE EXIT HANDLER FOR NOT FOUND 
  57.            SIGNAL SQLSTATE '80000'  
  58.                SET MESSAGE_TEXT='TRIG Not Found';  
  59. DECLARE EXIT HANDLER FOR SQLWARNING 
  60.            SIGNAL SQLSTATE '80001'  
  61.                SET MESSAGE_TEXT='Unable to disable TRIG';  
  62. INSERT INTO ARC.ARC_DISABLED_TRIGS 
  63. SELECT 
  64.     TRIGSCHEMA, TRIGNAME, OWNER, TABSCHEMA, TABNAME, 
  65.     QUALIFIER, FUNC_PATH, CAST(TEXT as VARCHAR(31500))
  66. FROM SYSCAT.TRIGGERS
  67. WHERE TRIGSCHEMA = v_schema and TRIGNAME = v_name 
  68.           AND VALID='Y';  
  69. SET v_stmt =  'DROP TRIGGER ' || v_schema || '.' ||v_name; 
  70. EXECUTE IMMEDIATE v_stmt; 
  71. END
  72. $
  73.  
Jan 23 '12 #1

✓ answered by rjj1

I called each stored procedure separately in my stored procedure, and it works now.

[code]
CONNECT RESET
$
CONNECT TO MAXDB71

$
DROP PROCEDURE ARC.ARC_RESTORE
$

CREATE PROCEDURE ARC.ARC_RESTORE ()
LANGUAGE SQL
BEGIN ATOMIC
DECLARE stmt varchar(32000) default ' ';

set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''LONGDESCRIPTION_ T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''LONGDESCRIPTION_ U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''COMMLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''COMMLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PLUSPTKPRICETOT_ T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PLUSPTKPRICETOT_ U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PERSISTSTATUS_T' ')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PERSISTSTATUS_U' ')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKVIEW_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKVIEW_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TKSTATUS_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TKSTATUS_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TICKET_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TICKET_U'')
';
execute immediate stmt;


-- Call your routines here

set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''LONGDESCRIPTION_T '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''LONGDESCRIPTION_U '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''COMMLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''COMMLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PLUSPTKPRICETOT_T '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PLUSPTKPRICETOT_U '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PERSISTSTATUS_T'' )
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PERSISTSTATUS_U'' )
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKVIEW_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKVIEW_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TKSTATUS_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TKSTATUS_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TICKET_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TICKET_U'')
';
execute immediate stmt;

END
$
[code]

1 2692
rjj1
2
I called each stored procedure separately in my stored procedure, and it works now.

[code]
CONNECT RESET
$
CONNECT TO MAXDB71

$
DROP PROCEDURE ARC.ARC_RESTORE
$

CREATE PROCEDURE ARC.ARC_RESTORE ()
LANGUAGE SQL
BEGIN ATOMIC
DECLARE stmt varchar(32000) default ' ';

set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''LONGDESCRIPTION_ T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''LONGDESCRIPTION_ U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''COMMLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''COMMLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PLUSPTKPRICETOT_ T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PLUSPTKPRICETOT_ U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PERSISTSTATUS_T' ')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''PERSISTSTATUS_U' ')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKVIEW_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''WORKVIEW_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TKSTATUS_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TKSTATUS_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TICKET_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_disable_trig(''MAXIMO'',''TICKET_U'')
';
execute immediate stmt;


-- Call your routines here

set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''LONGDESCRIPTION_T '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''LONGDESCRIPTION_U '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''COMMLOG_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''COMMLOG_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PLUSPTKPRICETOT_T '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PLUSPTKPRICETOT_U '')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PERSISTSTATUS_T'' )
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''PERSISTSTATUS_U'' )
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKVIEW_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''WORKVIEW_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TKSTATUS_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TKSTATUS_U'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TICKET_T'')
';
execute immediate stmt;
set stmt = '
CALL ARC.arc_enable_trig(''MAXIMO'',''TICKET_U'')
';
execute immediate stmt;

END
$
[code]
Jan 25 '12 #2

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

Similar topics

1
by: Ryan | last post by:
We have a suppliers application that runs a stored procedure (one of many). This stored procedure then calls various other ones etc... and the final number of stored procedures run is 11. Now,...
3
by: Jarrod Morrison | last post by:
Hi all Im relatively new to using stored procedures and im not sure if it is possible to do what I am trying to do so any help here is greatly appreciated. I am using the variable @MachineName...
5
by: ahokdac-sql | last post by:
Hi, I'm adapting access queries to sql server and I have difficulties with the following pattern : query1 : SELECT * FROM Query2 WHERE A=@param1 query 2: SELECT * FROM Table2 WHERE B=@param2 ...
7
by: Anthony Robinson | last post by:
Have been encountering an odd issue. Every now and again, certain packages of stored procedures just become invalid. I'm aware that dropping or altering an underlying table would render a package...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
2
by: Twan Kennis | last post by:
Question: How do I pass a returning resultset from a nested Stored Procedure (which opens a cursor including option "WITH RETURN TO CALLER") as a returning resultset from it's own? When I...
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
1
by: sasachi sachi sachi | last post by:
Hi there, I have a data manipulation process written in a Nested Stored procedure that have four levels deeper. When I run these individual procedures individually they all seems to be fine....
1
by: svkreddy | last post by:
Dear All, Please provide the simple information about stored procedures and stored functions in microsoft sql server2005. Please give the information about Nested procedures and nested funtions....
3
by: codefragment | last post by:
Hi I have a chunky bit of sql that I will want to call from a number of places. It will return a few thousand rows. Whats the best way of structuring this? 1) I initially thought of using...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.