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 > Will Calling Procedure from user defined function work in DB2 v8 for Windows????

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-25-04, 02:10
Jake K Jake K is offline
Registered User
 
Join Date: Feb 2004
Posts: 107
Will Calling Procedure from user defined function work in DB2 v8 for Windows????

Will Calling a Procedure from user defined function work in DB2 v8 for Windows????

it throws the below error while i try to compile:
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 "CALL TEMP_GET_INT_VARIABLE" was found following
"ALUE INT default 0; ". Expected tokens may include: "<compound_return>".
LINE NUMBER=7. SQLSTATE=42601


Example:
---------------------------------------------------------------------------
CREATE PROCEDURE TEMP_GET_INT_VARIABLE(p_v int)
RESULT SETS 0
LANGUAGE SQL
NOT DETERMINISTIC
BEGIN
DECLARE var int;
END
@

CREATE FUNCTION GET_INT_VARIABLE(P_VAR_NAME VARCHAR(2000))
RETURNS INT
LANGUAGE SQL
MODIFIES SQL DATA
BEGIN ATOMIC
DECLARE INT_VALUE INT default 0;
CALL TEMP_GET_INT_VARIABLE(1);
RETURN INT_VALUE;
END
@
---------------------------------------------------------------------------

appreciate any help regarding this problem....

Jake
Reply With Quote
  #2 (permalink)  
Old 11-25-04, 09:31
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by Jake K
Will Calling a Procedure from user defined function work in DB2 v8 for Windows????

it throws the below error while i try to compile:
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 "CALL TEMP_GET_INT_VARIABLE" was found following
"ALUE INT default 0; ". Expected tokens may include: "<compound_return>".
LINE NUMBER=7. SQLSTATE=42601


Example:
---------------------------------------------------------------------------
CREATE PROCEDURE TEMP_GET_INT_VARIABLE(p_v int)
RESULT SETS 0
LANGUAGE SQL
NOT DETERMINISTIC
BEGIN
DECLARE var int;
END
@

CREATE FUNCTION GET_INT_VARIABLE(P_VAR_NAME VARCHAR(2000))
RETURNS INT
LANGUAGE SQL
MODIFIES SQL DATA
BEGIN ATOMIC
DECLARE INT_VALUE INT default 0;
CALL TEMP_GET_INT_VARIABLE(1);
RETURN INT_VALUE;
END
@
---------------------------------------------------------------------------

appreciate any help regarding this problem....

Jake
You should be able to call a procedure from a UDF... I think your issue is actually that you can't have "MODIFIES SQL DATA" in a function unless it returns a table.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 11-26-04, 02:20
Jake K Jake K is offline
Registered User
 
Join Date: Feb 2004
Posts: 107
i think MODIFIES SQL DATA is not the reason... to make myself sure about it, i removed it and compiled the procedure once again... .the same error occurs... as far as i know MODIFIES SQL DATA tells the database that the function modifies data persisted in the database...

Jake
Reply With Quote
  #4 (permalink)  
Old 11-26-04, 07:10
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by Jake K
i think MODIFIES SQL DATA is not the reason... to make myself sure about it, i removed it and compiled the procedure once again... .the same error occurs... as far as i know MODIFIES SQL DATA tells the database that the function modifies data persisted in the database...

Jake
In the SQL Ref volume 2 under CREATE FUNCTION you'll note that "MODIFIES SQL DATA" has a foot note (1), and that footnote reads:

"Notes: 1 Valid only if RETURNS specifies a table (TABLE column-list)"

What version of db2 are you using? When I copy and paste your exact definitions I see this error:

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0628N Multiple or conflicting keywords involving the "MODIFIES SQL DATA"
clause are present. LINE NUMBER=10. SQLSTATE=42613
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #5 (permalink)  
Old 11-30-04, 14:05
Alairj Alairj is offline
Registered User
 
Join Date: Nov 2004
Location: São Paulo, Brazil
Posts: 32
It's happenig the same problem with me, if you find a solution please, tell us, my db2 version is the latest 8.2.

Thanks.
Reply With Quote
  #6 (permalink)  
Old 12-03-04, 01:12
Jake K Jake K is offline
Registered User
 
Join Date: Feb 2004
Posts: 107
sorry for the late reply.... i'm using DB2 v8.1.3 for Windows

Jake
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