473,785 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems when run one procedure in DB2

Hi to all !!! And thanks to answer my topics.

I have problems when I try of run stored procedures, show diferents
errors. I made one test with one example of the tutorials. The example
is this

CREATE PROCEDURE RETURN_DEPT_SAL ARY
(IN DEPT_NUMBER CHAR(3),
OUT DEPT_SALARY DECIMAL(15,2),
OUT DEPT_BONUS_CNT INT)
LANGUAGE SQL READS SQL DATA
P1: BEGIN
DECLARE EMPLOYEE_SALARY DECIMAL(9,2);
DECLARE EMPLOYEE_BONUS DECIMAL(9,2);
DECLARE TOTAL_SALARY DECIMAL(15,2)DE FAULT 0
DECLARE BONUS_CNT INT DEFAULT 0;
DECLARE END_TABLE INT DEFAULT 0;
DECLARE C1 CURSOR FOR
SELECT SALARY, BONUS FROM RJOHNSON.EMPLOY EE
WHERE WORKDEPT = DEPT_NUMBER;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET END_TABLE = 1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SET DEPT_SALARY = NULL;
OPEN C1;
FETCH C1 INTO EMPLOYEE_SALARY , EMPLOYEE_BONUS;
WHILE END_TABLE = 0 DO
SET TOTAL_SALARY = TOTAL_SALARY + EMPLOYEE_SALARY +
EMPLOYEE_BONUS;
IF EMPLOYEE_BONUS 0 THEN
SET BONUS_CNT = BONUS_CNT + 1;
END IF;
FETCH C1 INTO EMPLOYEE_SALARY , EMPLOYEE_BONUS;
END WHILE;
CLOSE C1;
SET DEPT_SALARY = TOTAL_SALARY;
SET DEPT_BONUS_CNT = BONUS_CNT;
END P1;

And show between others message like these

DECLARE EMPLOYEE_SALARY DECIMAL(9,2)
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
"_SALARY
DECIMAL(9,2)". Expected tokens may include: "<psm_semicolon >". LINE
NUMBER=7. SQLSTATE=42601

DECLARE EMPLOYEE_BONUS DECIMAL(9,2)
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 "DECLARE EMPLOYEE_BONUS DECIMAL" was
found
following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>".
SQLSTATE=42601

If I change the ";" for "," show others messages

I made stored procedure but show same messages.

Somebody know what is the problem?

Of new thanks to all for answer

Iván

Aug 28 '06 #1
4 7639

Ivan wrote:
Hi to all !!! And thanks to answer my topics.

I have problems when I try of run stored procedures, show diferents
errors. I made one test with one example of the tutorials. The example
is this
END P1;
hi,

remove the semicolon at the last

1) u have specified "END P1;" change it to "END P1"

2) look at this DECLARE TOTAL_SALARY DECIMAL(15,2)DE FAULT 0

put semicolon for this at last like

DECLARE TOTAL_SALARY DECIMAL(15,2) DEFAULT 0;

Aug 28 '06 #2
I made the change indicates but the problem is the same.

Which semicolon I should removed?

Thanks

Iván.
DECLARE EMPLOYEE_SALARY DECIMAL(9,2)
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
"_SALARY
DECIMAL(9,2)". Expected tokens may include: "<psm_semicolon >". LINE
NUMBER=7. SQLSTATE=42601

DECLARE EMPLOYEE_BONUS DECIMAL(9,2)
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 "DECLARE EMPLOYEE_BONUS DECIMAL" was
found
following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>".
SQLSTATE=42601

situ wrote:
Ivan wrote:
Hi to all !!! And thanks to answer my topics.

I have problems when I try of run stored procedures, show diferents
errors. I made one test with one example of the tutorials. The example
is this
END P1;

hi,

remove the semicolon at the last

1) u have specified "END P1;" change it to "END P1"

2) look at this DECLARE TOTAL_SALARY DECIMAL(15,2)DE FAULT 0

put semicolon for this at last like

DECLARE TOTAL_SALARY DECIMAL(15,2) DEFAULT 0;
Aug 28 '06 #3
If you want to go this route of statement termination, remove the very
last semicolon (after the final "END"). Do put a smeicolon after
"DECLARE EMPLOYEE_SALARY DECIMAL(9,2)," however.

--Jeff

Ivan wrote:
I made the change indicates but the problem is the same.

Which semicolon I should removed?

Thanks

Iván.
DECLARE EMPLOYEE_SALARY DECIMAL(9,2)
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
"_SALARY
DECIMAL(9,2)". Expected tokens may include: "<psm_semicolon >". LINE
NUMBER=7. SQLSTATE=42601

DECLARE EMPLOYEE_BONUS DECIMAL(9,2)
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 "DECLARE EMPLOYEE_BONUS DECIMAL" was
found
following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<values>".
SQLSTATE=42601

situ wrote:
Ivan wrote:
Hi to all !!! And thanks to answer my topics.
>
I have problems when I try of run stored procedures, show diferents
errors. I made one test with one example of the tutorials. The example
is this
>
END P1;
>
hi,

remove the semicolon at the last

1) u have specified "END P1;" change it to "END P1"

2) look at this DECLARE TOTAL_SALARY DECIMAL(15,2)DE FAULT 0

put semicolon for this at last like

DECLARE TOTAL_SALARY DECIMAL(15,2) DEFAULT 0;
Aug 28 '06 #4
jefftyzzer wrote:
If you want to go this route of statement termination, remove the very
last semicolon (after the final "END"). Do put a smeicolon after
"DECLARE EMPLOYEE_SALARY DECIMAL(9,2)," however.
Something else to check is that you don't have Windows end-of-line and
carriage-return characters in your SQL script. Otherwise, DB2 won't accept
the statement terminator as such.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Aug 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8563
by: A.M. de Jong | last post by:
When I perform a query on a linked Oracle server in the Query analyser I have no prboblem' to perform this query. However, when I create this query in a stored procedure I get a compilation error when saving this procedure. (Not when compiling; it has no errors) Server: Msg 7405, Level 16, State 1, Line 1 Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query...
5
6055
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 update_salary (in emp_number char(6), in rate integer) language sql begin update employee
3
2806
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all critical service applied). I've written...
3
1728
by: Henry Reardon | last post by:
I installed DB2 for Linux, Unix, and Windows on V8.2 (i.e. 8.1.7) on Windows XP on Friday. I had some problems with migration which are still outstanding - see my earlier thread - but I managed to drop the old SAMPLE database and create a new one that works fine. That enabled me to resume work on my current project. However, I am having problems with UDFs over and above the ones I mentioned in the earlier thread. I have a UDF that worked...
9
3764
by: serge | last post by:
I have a stored procedure that is over 1000 + lines of code. When i try to compile I get the following error: ABC.TEST123: 1285: SQL0104N An unexpected token "END" was found following " END IF; END IF; ". Expected tokens may include: "END". LINE NUMBER=1285. SQLSTATE=42601 I tried creating a new tablespace + buffer pool on this database but still
6
3657
by: Not Me | last post by:
Hi, I have a stored procedure as a recordsource for a form, taking a parameter from another form, it displays records that are already present without any problems. I had to add a resync command to allow edits, but it works ok for now. The problem is when creating new records. If I open the form with datamode acFormAdd, I get the blank record fine, I can populate the fields ok. but when I come to close the record, I get the error
1
3067
by: Chad Dittmer via .NET 247 | last post by:
I'm having problems inserting into Sql 2000 using SqlHelper.ExecuteScalar. When it inserts, it only takes the first character from the string?? Any help would be appreciated. Here is the code and the stored procedure I'm using. Dim newRowId As Integer newRowId = Convert.ToInt32(SqlHelper.ExecuteScalar(ConfigurationSettings.AppSettings("ConnectionString"), "ProcContactsInsert", 1234, "hparameter2", "parameter2", "tparamer2", "pareter2",...
4
2762
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx to a stored procedure on the details2.aspx page. I can successfully pass the values from the listbox control to a
1
6364
by: Ir0neagle | last post by:
I am generating upgrade/new install scripts for my project. I am able to do this in oracle and sql server but an running into problems in db2. What I am trying to do is to use some logic to only create table that have not been generated in prevous releases. I am trying to create a stored procedure to do this. I am not able to create the stored procedure because it errors out with the error below. I am stumped as how to get around this...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.