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

Error in Stored Procedure (DB21034E)

Hi All,

I am new to Stored Procedures, Cursors. I am getting an error "DB21034E The command was processed as an SQL statement because it was invalid Command Line Processor command. During SQL processing it returned SQL0104N An unexpected token "FOR" was found following "FOR P_DYN_STMT1” Expected tokens may include: "FROM". LINE NUMBER=13. SQLSTATE=42601" when I try to create this stored procedure in DB2 UDB

CREATE PROCEDURE CER_MKTG.P_CHNL_FLG_SET_ALL_LOB()
MODIFIES SQL DATA
LANGUAGE SQL
BEGIN
DECLARE P_STMT1 VARCHAR(1000);
DECLARE P_STMT2 VARCHAR(1000);
DECLARE P_CHNL VARCHAR(100);
DECLARE P_LOB VARCHAR(100);
DECLARE A VARCHAR(100);
DECLARE P_RC INTEGER;
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE C1 CURSOR FOR P_DYN_STMT1;
FOR LOBF, CHANNELF AS SELECT DISTINCT LOB, CHANNEL_FLAG FROM CER_MKTG.SUPPRESSION_GRID
DO
SET P_STMT1 = '';
SET P_CHNL = '';
SET P_LOB = '';
SET P_STMT1 = 'UPDATE CER_MKTG.LOB_SUPPRESSION_TEST SET ';
SET P_CHNL = CHANNELF;
SET P_LOB = LOBF;
SET P_STMT1 = P_STMT1 || P_CHNL || '_FLG = ''Y'' WHERE SUPPRESSION_TYPE = '''|| P_LOB ||''' AND (';
SET P_STMT2 = 'SELECT SCRUB_NAME FROM CER_MKTG.SUPPRESSION_GRID WHERE LOB = '''|| P_LOB || ''' AND
CHANNEL_FLAG = ''' || P_CHNL || '''';
SET P_RC = (SELECT COUNT(*) FROM CER_MKTG.SUPPRESSION_GRID WHERE LOB = P_LOB AND CHANNEL_FLAG = P_CHNL);
INSERT INTO CER_MKTG.SCRUB_STATEMENT VALUES(CHAR(P_RC));
PREPARE P_DYN_STMT1 FROM P_STMT2;
OPEN C1;
SET A = '';
FETCH C1 INTO A;
WHILE (SQLCODE=0) DO
SET P_STMT1 = P_STMT1 || ' ' ||A || ' +';
INSERT INTO CER_MKTG.SCRUB_STATEMENT VALUES(CHAR(P_RC));
SET P_RC = P_RC - 1;
SET A = '';
FETCH C1 INTO A;
END WHILE;
CLOSE C1;
SET P_STMT1 = LEFT(P_STMT1,LENGTH(P_STMT1)-1) || ' ) = 0';
INSERT INTO CER_MKTG.SCRUB_STATEMENT VALUES(P_STMT1);
INSERT INTO CER_MKTG.SCRUB_STATEMENT VALUES(P_STMT2);

PREPARE P_DYN_STMT2 FROM P_STMT1;
SET P_STMT2 = '';
SET P_STMT2 = 'ALTER TABLE CER_MKTG.LOB_SUPPRESSION_TEST ACTIVATE NOT LOGGED INITIALLY';
PREPARE P_DYN_STMT1 FROM P_STMT2;
EXECUTE P_DYN_STMT1;
EXECUTE P_DYN_STMT2;
SET P_STMT2 = '';
SET P_STMT2 = 'COMMIT';
PREPARE P_DYN_STMT1 FROM P_STMT2;
EXECUTE P_DYN_STMT1;
END FOR;
END!

Any thoughts why I am getting this error and how to resolve it?

Thanks in advance,
Saravanan
Aug 1 '08 #1
4 8103
Hi
Rather than using END! at the and of procedure try END@

Morarji
Aug 8 '08 #2
Hi Morarji,

I tried with END @, it did not work. so I replaced the for statement with a cursor which now works fine. Thanks for your help!

Saravanan
Aug 11 '08 #3
Hi saravana.....

When the same problem came for me i did this......and solved..... any way you got the solution in another way..... cheer up.......


Can you suggest me..... How to improve my DB2 server speed.......

Thanks is advance

Morarji
Aug 11 '08 #4
CREATE PROCEDURE SHREYADB.PAYMENT1()
BEGIN
UPDATE CUSTOMER SET CUSTOMERADDRESS='DARBYTOWNPLACE' WHERE CUSTOMERID='cust222';
END!

Hi I am new to storedprocedure when try to run the above code it is giving the below error code.
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "END".
Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601

SQL0104N An unexpected token "END-OF-STATEMENT" was found following "END". Expected tokens may include: "JOIN <joined_table> ".

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.

As an aid, a partial list of valid tokens is provided in the
SQLERRM field of the SQLCA as "<token-list>". This list assumes
the statement is correct to that point.

The statement cannot be processed.

User Response:

Examine and correct the statement in the area of the specified
token.

sqlcode : -104

sqlstate : 42601
Jun 15 '09 #5

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

Similar topics

7
by: Alex | last post by:
Hi all, I am trying to install a java stored procedure via the windows development centre. The linux box is running 8.1 FP4 as is the windoze platform. If I am on the linux box i can install...
5
by: Lili | last post by:
I'm having problems creating a simple stored procedure in DB2. Can someone help? Here is the screen dump when I tried to load the stored procedure. Thanks for any help. Create procedure...
2
by: Solomon Obi | last post by:
I am running DB2 Express V 8.1 on Windows XP I have installed the Visual C/C++ compiler the command to invoke the compiler is cl I am attempting to install the stored procedure defined below ...
3
by: Bob Gabor | last post by:
Running 8.1 w/FP5 on Windows 2000. Everytime I try to create a stored procedure, I get the following error saying that my database is damaged: DB21034E The command was processed as an SQL...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
1
by: UDBDBA | last post by:
Hi: How can one call SYSPROC.DB2LOAD procedure within a SQL stored procedure. I get the following error: DB21034E The command was processed as an SQL statement because it was not a valid...
4
by: Pakna | last post by:
Hi, is there any way to call a JAVA stored procedure from a SQL Trigger? We are having difficulties with this and cannot verify whether DB2 even *has* this capability? Thank you very much....
0
by: Johan Neidenmark | last post by:
When i try to run this SQL statements in iSeries Access for windows (against my customers db2) i get: SQL State: 42904 Vendor Code: -7032 Message: SQL procedure, function, or trigger...
2
by: gjain12 | last post by:
When I am trying to declare a cursor over a temproay table in my stored procedure I am getting some errors. Below are the piece of code from my stored procedure in which I am getting error. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.