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

I can't run strored procedure in Command Editor DB2

Hi I am new in DB2, and I have some problems when I try run stored
procedures, and others statements. I made one stored procedure very
simple, but this show different messages.

I have followed the indications that have said me in answer to topics,
but without positive results

This is the stored procedure

CREATE PROCEDURE TESTS ( )
-- DYNAMIC RESULT SETS 1
LANGUAGE SQL MODIFIES SQL DATA

P: BEGIN ATOMIC
FOR V1 AS
SELECT B.CLIENTID AS IDCLIENTID,
B.MAPPEDCLIENTID AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTID
DO
DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID;
END FOR;
END P

This is the message

DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID
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
"LIENTID
= IDCLIENTID". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=15. SQLSTATE=42601

END FOR
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
FOR". Expected tokens may include: "JOIN <joined_table>".
SQLSTATE=42601

Explanation:

A syntax error in the SQL statement was detected at the specified
token following the text "<text>". The "<text>" field indicates
the 20 characters of the SQL statement that preceded the token
that is not valid.

As an aid to the programmer, 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.

Thanks for its amiability.

Greetings

Iván

Aug 29 '06 #1
8 21043
Here is a sample

CREATE PROCEDURE shashi.test ( IN p1 int, IN p2 int, OUT p3 INT)
LANGUAGE SQL
BEGIN
SET p2=p2+1;
SET p3=2*p1;
END
@

Now save that in a file and run it like this

db2 -td@ -vf <file>

Now call it like this....

db2 "call shashi.test(1,2,?)"

cheers..
Shashi Mannepalli
Ivan wrote:
Hi I am new in DB2, and I have some problems when I try run stored
procedures, and others statements. I made one stored procedure very
simple, but this show different messages.

I have followed the indications that have said me in answer to topics,
but without positive results

This is the stored procedure

CREATE PROCEDURE TESTS ( )
-- DYNAMIC RESULT SETS 1
LANGUAGE SQL MODIFIES SQL DATA

P: BEGIN ATOMIC
FOR V1 AS
SELECT B.CLIENTID AS IDCLIENTID,
B.MAPPEDCLIENTID AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTID
DO
DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID;
END FOR;
END P

This is the message

DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID
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
"LIENTID
= IDCLIENTID". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=15. SQLSTATE=42601

END FOR
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
FOR". Expected tokens may include: "JOIN <joined_table>".
SQLSTATE=42601

Explanation:

A syntax error in the SQL statement was detected at the specified
token following the text "<text>". The "<text>" field indicates
the 20 characters of the SQL statement that preceded the token
that is not valid.

As an aid to the programmer, 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.

Thanks for its amiability.

Greetings

Iván
Aug 29 '06 #2
Ivan,

In command editor you should define terminator (look at the screen
bottom), different than semicomma, because semicomma is a part of SQL
PL language. In version 9 terminator can be double character, for
example @@

Shashi gave you the way to create stored procedure from command line
processor, but why not to look at DB2 Developer Workbench? It's
free.

http://www-306.ibm.com/software/data.../download.html

-- Artur Wronski

Aug 29 '06 #3
Thanks Artur, but I don't know where define terminator, what is the
bottom?

Greetings

Iván

Artur wrote:
Ivan,

In command editor you should define terminator (look at the screen
bottom), different than semicomma, because semicomma is a part of SQL
PL language. In version 9 terminator can be double character, for
example @@

Shashi gave you the way to create stored procedure from command line
processor, but why not to look at DB2 Developer Workbench? It's
free.

http://www-306.ibm.com/software/data.../download.html

-- Artur Wronski
Aug 30 '06 #4
Thanks Shashi.

I made the test but wasn't successful. Show diferentes messages like
this

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
"QL BEGIN
SET p2=p2+1". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=4. SQLSTATE=42601

If I change the ";" for "," or without nothing show others messages,
but don't make nothing.
Greetings!!!

Iván

Shashi Mannepalli wrote:
Here is a sample

CREATE PROCEDURE shashi.test ( IN p1 int, IN p2 int, OUT p3 INT)
LANGUAGE SQL
BEGIN
SET p2=p2+1;
SET p3=2*p1;
END
@

Now save that in a file and run it like this

db2 -td@ -vf <file>

Now call it like this....

db2 "call shashi.test(1,2,?)"

cheers..
Shashi Mannepalli
Ivan wrote:
Hi I am new in DB2, and I have some problems when I try run stored
procedures, and others statements. I made one stored procedure very
simple, but this show different messages.

I have followed the indications that have said me in answer to topics,
but without positive results

This is the stored procedure

CREATE PROCEDURE TESTS ( )
-- DYNAMIC RESULT SETS 1
LANGUAGE SQL MODIFIES SQL DATA

P: BEGIN ATOMIC
FOR V1 AS
SELECT B.CLIENTID AS IDCLIENTID,
B.MAPPEDCLIENTID AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTID
DO
DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID;
END FOR;
END P

This is the message

DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID
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
"LIENTID
= IDCLIENTID". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=15. SQLSTATE=42601

END FOR
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
FOR". Expected tokens may include: "JOIN <joined_table>".
SQLSTATE=42601

Explanation:

A syntax error in the SQL statement was detected at the specified
token following the text "<text>". The "<text>" field indicates
the 20 characters of the SQL statement that preceded the token
that is not valid.

As an aid to the programmer, 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.

Thanks for its amiability.

Greetings

Iván
Aug 30 '06 #5
Ivan, which tool are you using? Do you use CLP (e.e. you type db2 from a
shell), Command Editor, Developer Center, Developer Workbench?
Do you use a text editor?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 30 '06 #6
Thanks Serge for answer.

I'm working with DB2 v8 and using Command Editor, and it is the stored
procedure that I made.

Greetings.
Iván

CREATE PROCEDURE TESTS ( )
-- DYNAMIC RESULT SETS 1
LANGUAGE SQL MODIFIES SQL DATA
P: BEGIN ATOMIC
FOR V1 AS
SELECT B.CLIENTID AS IDCLIENTID,
B.MAPPEDCLIENTID AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTID
DO
DELETE FROM EIS.CLI_BANK
WHERE CLIENTID = IDCLIENTID;
END FOR;
END P
Serge Rielau wrote:
Ivan, which tool are you using? Do you use CLP (e.e. you type db2 from a
shell), Command Editor, Developer Center, Developer Workbench?
Do you use a text editor?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 30 '06 #7
Ivan wrote:
Thanks Serge for answer.

I'm working with DB2 v8 and using Command Editor, and it is the stored
procedure that I made.
OK, at the bottom of the command editor window is a tiny textbox.
In English versions it says "termination character" in blue in front of
it. When you bring up command editor the text box should contain a
semicolon (;).
All you need to do is edit the textbox to be a "@" or perhaps a dollar
"$" sign.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 30 '06 #8
Thanks Serge.

Finally I can run the stored procedure, by something so simple that
have taken weeks.

Grettings
Iván

Serge Rielau wrote:
Ivan wrote:
Thanks Serge for answer.

I'm working with DB2 v8 and using Command Editor, and it is the stored
procedure that I made.
OK, at the bottom of the command editor window is a tiny textbox.
In English versions it says "termination character" in blue in front of
it. When you bring up command editor the text box should contain a
semicolon (;).
All you need to do is edit the textbox to be a "@" or perhaps a dollar
"$" sign.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 31 '06 #9

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

Similar topics

1
by: tc | last post by:
Hi, all I would like to ask how can I execute a command(e.g. dir/w) by using C#? Thanks
1
by: Àä×ÔȪ | last post by:
Can i invoke SSE command with c#??? Thanks for any way!!!
0
by: project | last post by:
I want to print an sales invoice with out open crystal report. I want to know ,with out opening Crystal report, how can I give the command to be printing invoice. I'm using the following lines...
7
by: Aj-India | last post by:
Is there anyway that I could preserve the comments when creating an SP from Command Editor,so that when i import the SP in the development center I can see them. The reason for such a request is...
0
by: Kevin Edwards | last post by:
Hi, all Running a query via Command Editor from a DB2UDB V8 Windows2000 client, if I cancel the executing query the query seems to just carry on anyway (unlike Command Center which used to...
0
by: rxding | last post by:
Can Java Store Procedure increase performance Hello, Performance reason we need to move some of our code into database. Java Store Procedure is given the first choice. However, while...
0
by: shanmugam | last post by:
Hi All How can i hide the command prompt window when executing the system command in perl. Thanks in advance Shanmugam
2
by: db2learner | last post by:
Hi, I am new to DB2 and i just started worked on it a couple of days back. I have created basic EMPLOYEE table from control centre which has 2 fields: EmpNo, EmpName. I am trying to write...
1
by: norseman | last post by:
Ty hensons wrote: ============================================== That by itself leaves lots of questions. Taken literally to be the "box" then: In Microsoft use the "Print Screen" followed...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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
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.