473,396 Members | 2,108 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,396 software developers and data experts.

Executing a DB2 stored procedure in Unix Environment.

Hi I am Uma. I am new to DB2 and Unix(AIX) Environment. Can any one please help me to how to execute a DB2 stored procedure in Unix Environment. Thanks a lot.
Jun 4 '08 #1
2 4225
sakumar9
127 Expert 100+
You can follow these steps:
1. If your stored procedure is in any external language like C, Java, cobol etc, then compile it and paste the object file in sqllib/functions directory.

Recommended method: Go to sqllib/samples directory. Then go to the directory corresponding to the language in which you have written stored procedure. And give following command:
bldrtn <filename> --- Filename should be without extensions.
This will compile and put the object file at desired location.

2. If your stored procedure is in CLP, then you just need to execute the command, and SP is ready for use.

3. Execute CREATE PROCEDURE command to catalog the SP in DB2.
4. Done , now you can use the SP.


Let me know if you have any problems.

Regards
-- Sanjay
Jun 5 '08 #2
Hi Sanjay,

Thank you so much for the reply. the SP is sql and it uses cursor inside it.It also contains CREATE PROCEDURE command even. I am trying to execute it by pasting it in a file and giving the command db2 -tvsf <filename>. But it gives me lot of errors.

Eg:- Please look into the below error.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
select current timestamp from sysibm.sysdummy1

1
--------------------------
2008-06-05-08.36.06.720460

1 record(s) selected.


CREATE PROCEDURE pharm.PJSP094hkp_presitm ( OUT SQLCODE_OUT int,
OUT SQLTEXT varchar(1000), OUT rows_processed int)
RESULT SETS 1
LANGUAGE SQL


PJSP094P1: BEGIN
DECLARE SQLCODE INT DEFAULT 0
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 "QLCODE
INT DEFAULT 0". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=8. SQLSTATE=42601

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~

And in the error it is giving like expecting semicolon which is already present at that line ending. I am unable to figure out why it is giving. And if we are executing normal DB2 quries we are able to run with out any errors. The entire code is correct and unable to figure out why we are getting this error.

Can you please help us in this regard.
Thanks a lot Sanjay.

Thanks & Regards,
Uma G


You can follow these steps:
1. If your stored procedure is in any external language like C, Java, cobol etc, then compile it and paste the object file in sqllib/functions directory.

Recommended method: Go to sqllib/samples directory. Then go to the directory corresponding to the language in which you have written stored procedure. And give following command:
bldrtn <filename> --- Filename should be without extensions.
This will compile and put the object file at desired location.

2. If your stored procedure is in CLP, then you just need to execute the command, and SP is ready for use.

3. Execute CREATE PROCEDURE command to catalog the SP in DB2.
4. Done , now you can use the SP.


Let me know if you have any problems.

Regards
-- Sanjay
Jun 5 '08 #3

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

Similar topics

7
by: Jeff Wang | last post by:
Hi all, Can someone help me out? I've been struggling with this for almost a week and still have no clue what's wrong. Basically I want to write a DB2 stored procedure for OS/390 in REXX. In...
1
by: DB_2 | last post by:
Hello, I created the following stored procedure. (Please ignore the logic in it; at this point it is not complete and I am trying to get the basic structure working first.) CREATE PROCEDURE...
5
by: JS | last post by:
I have v8.1 fix 5 installed on windows 2k. I compiled a stored procedure in development environment, then used the get routine command to generate the file. I transferred the file to second test...
1
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
2
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
0
by: Marco Vasquez | last post by:
Currently, we are using the next tool in order to execute SQL commands in DB2 databases: About DB2 Administration Tools Environment...
9
by: Leedrick | last post by:
Hi, In the past I have been dealing mainly with sql server, and recently been given the task of supporting software that uses db2 on as400. Simple tasks such as executing a stored procedure...
3
by: ckauvar | last post by:
The PHP below calls a stored procedure in a MSSQL database when I am using SQL in a Windows environment. I've recently switched to a UNIX environment and am now using ODBC (via FreeTDS) to connect...
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:
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: 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...
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
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...
0
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...
0
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,...

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.