473,769 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.MAPPEDCLIENTI D AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTI D
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 21087
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.MAPPEDCLIENTI D AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTI D
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.MAPPEDCLIENTI D AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTI D
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.MAPPEDCLIENTI D AS MAPPED
FROM EIS.CLI_MAPING B
WHERE
B.STATUSID = 3 AND
B.CLIENTID != B.MAPPEDCLIENTI D
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 "terminatio n 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 "terminatio n 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
1245
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
1594
by: Àä×ÔȪ | last post by:
Can i invoke SSE command with c#??? Thanks for any way!!!
0
291
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 to open a crystal report Dim myreport as new reportdocument() Dim Rptfrm as new project1.reportfrm()
7
1632
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 that I am moving SP's from the development environment to the production environment and would prefer to run them as a script in command editor. Cheers, Aj
0
1433
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 confirm that it had been cancelled) but more importantly database locks seem to be maintained that can cause alerts on our monitoring software. Usual action is for me to issue a commit even though I have nothing obviously running. Didn't get this...
0
1270
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 investigating some sample code of Java store procedure, PreparedStatement seems to be a must, such as PreparedStatement pstmt = conn.prepareStatement(sql); ..., pstmt.close() in the end. My question is that if the prepareStatement(sql) is called each...
0
1600
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
13108
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 a simple stored proc in db2 command editor to insert values into these fields. CREATE PROCEDURE EMP_PROC() LANGUAGE SQL BEGIN INSERT INTO EMPLOYEE VALUES(001, 'XYZ'); END
1
1488
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 by mspaint and Edit/paste (Or SHIFT-PrintScreen if whole screen showed up, I forget which it is. One does just the box that is hot while the other gets all)
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
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...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6662
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
5294
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
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
3558
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.