If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Build and deploy DB2 UDB stored procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-28-04, 12:44
latticesoft latticesoft is offline
Registered User
 
Join Date: Jun 2004
Posts: 34
Build and deploy DB2 UDB stored procedures

I wrote a tool to auto-generate the stored procedures for DB2 UDB and output as sql script file, Now I need to build and deploy the stored procedures to database server. Seems like db2 is somewhat different from SQL server and Oracle, first you need a C Compiler to build the stored procedures. Can anyone direct me to the documentation or manual show us how to build and deploy the stored procedures step by step?

In SQL Server and Oracle, life is very easy, you just open the sql script file in Query Analyzer or SQLPLus Worksheet, then execute the script and the procedures will be build and deploy to the database server.

Can we use DB2's stored procedure builder or Command Center to do the same thing?

Thanks in advance for help,

Kevin
Reply With Quote
  #2 (permalink)  
Old 06-28-04, 13:24
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
A suggestion using DB2 Command Line Processor. You can issue:

db2 -td@ -f proc.sql

Make sure you use a different EOF marker other than ; (as it is used as the end of line marker for SQL commands within the stored proc code).
Reply With Quote
  #3 (permalink)  
Old 06-29-04, 03:20
trinmoy trinmoy is offline
Registered User
 
Join Date: Nov 2003
Location: kualaumpur
Posts: 33
Thumbs up Deployment steps

The CREATE PROCEDURE Statement for SQL Stored Procedures requires a C/C++ compiler for successful execution. Prior to Version 7.2, DB2 required a compiler to be present on every system where the stored procedure will be deployed. From Version 7.2, it is sufficient to have the compiler on only one system for every OS platform. Two new commands were introduced to deploy the Stored Procedure developed/created on one system to another. GET ROUTINE Command for extracting the stored procedure and PUT ROUTINE Command for deploying the Stored procedure on another machine.

GET ROUTINE INTO filename FROM [SPECIFIC] PROCEDURE routine-name

The Specific name of the routine is used when two procedures exist with the same name. The specific name of a procedure can be obtained from the SYSCAT.PROCEDURES Table.

If ftp is used for file transfer, the binary mode should be used.

PUT ROUTINE FROM filename [OWNER new-owner] [USE REGISTERS]

The OWNER Name is used when the Stored Procedure is deployed in another instance with a different name.

USE REGISTERS uses the current values of CURRENT SCHEMA and CURRENT PATH Registry variables. If not used, the original ones at the source are used.
Reply With Quote
  #4 (permalink)  
Old 06-29-04, 14:50
latticesoft latticesoft is offline
Registered User
 
Join Date: Jun 2004
Posts: 34
Thank you for response. Now I understand how it works in DB2 to compile and deploy stored procedures. I used gcc as my c compile and run db2 -td@ -v sample.sql in my DB2 server's command window, the stored procedure was successfully built in the database server.

Kevin
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On