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

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_SALARY
(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)DEFAULT 0
DECLARE BONUS_CNT INT DEFAULT 0;
DECLARE END_TABLE INT DEFAULT 0;
DECLARE C1 CURSOR FOR
SELECT SALARY, BONUS FROM RJOHNSON.EMPLOYEE
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 7577

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)DEFAULT 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)DEFAULT 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)DEFAULT 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
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...
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...
3
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"...
3
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...
9
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...
6
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...
1
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...
4
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...

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.