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 > calling a sql stored proc from a sql user defined function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-14-05, 07:26
Arun Vijay Arun Vijay is offline
Registered User
 
Join Date: Oct 2005
Posts: 1
Angry calling a sql stored proc from a sql user defined function

hi ,,


how can i call a sql stored proc from a sql user defined function in db2.

i tried the following syntax but is not buliding

call StoredProcName();

please help asap


bye
Reply With Quote
  #2 (permalink)  
Old 10-15-05, 05:15
grahammartin grahammartin is offline
Registered User
 
Join Date: Apr 2005
Posts: 41
Here is an example:

CREATE FUNCTION demo.udf1 (i_input VARCHAR(4000))
RETURNS VARCHAR(4000)
LANGUAGE SQL
NOT DETERMINISTIC
specific udf1
READS SQL DATA
d2: BEGIN ATOMIC
DECLARE status VARCHAR(4000);
CALL demo.status(i_input, status);
RETURN status;
END d2@

The demo.status Procedure is defined as:

CREATE PROCEDURE demo.status ( IN i_input VARCHAR(4000),
OUT OUTPUT VARCHAR(4000) )
LANGUAGE SQL
READS SQL DATA
BEGIN
.......

So as you can see, it is important to have matching types as well as declaring the output from the Procedure within the UDF.

Graham Martin
http://www-306.ibm.com/software/data/db2/migration/
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