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

Calling a stored procedure in a user defined function

Hello,

I am trying to call a stored procedure in a user defined function.

Expand|Select|Wrap|Line Numbers
  1. CREATE FUNCTION test () 
  2. RETURNS DECIMAL (15,4) 
  3. LANGUAGE SQL 
  4.  
  5. READ SQL DATA 
  6. EXTERNAL ACTION 
  7.  
  8.  
  9.  
  10. F1: BEGIN 
  11. DECLARE VAR1 DECIMAL(15,4); 
  12. DECLARE VAR2 VARCHAR(256); 
  13.  
  14. call test1('C','F',545,VAR1,VAR2); 
  15.  
  16. RETURN var1; 
  17.  
  18.  
  19. END 
The Stored procedure 'test1' does a lot of SQL work inside it and finally gives two output parameters and does not any DML operation inside it.

Inside UDF 'test' when this stored procedure is called, following error is seen.

SQL0577N User defined routine <> (specific name
"") attempted to modify data but was not defined as MODIFIES SQL DATA or was
used in a context that does not allow MODIFIES SQL DATA. LINE NUMBER=29.
SQLSTATE=38002

I understand that Maximum allowed SQL access level in scaler UDF is READS SQL DATA and this is what my code is doing.

http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/inde x.jsp?topic=%2Fcom.ibm.db2.luw.apdv.routines.doc%2 F doc%2Fr0020478.html

Problem here is I could solve this in my Development Env and codes works really fine as expected, but when I was trying to deploy this call in other Enviroment, I got the above error. It proves conceptually and logically there is no problem in the code.

More or less looks to be an Environment Issue. Have done a rebind to the package got created for Stored Procedure.

Am I missing something.

OS: RHEL 5.5
DB2 - 9.7 FP4
Feb 27 '13 #1
0 1960

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

Similar topics

1
by: JHB | last post by:
Hi. I'm really new to MSSQL, so therefore my question can sound stupid. Is it possible to use a function written in a module in MS-ACCESS in a stored procedure? Or how can it be done, it is a...
2
by: Steve D | last post by:
I've looked all over but can't find a solid answer. I've got a function that runs from a View and when the function runs the first time it is calculating a Temperature for a group of Formulas. ...
3
by: Gary Besta | last post by:
I am trying to add a simple case statement to a stored procedure or user defined function. However when I try and save the function/procedure I get 2 syntax errors. Running the query in query...
1
by: Matt | last post by:
Is there any reason why I shouldn't cause an arithmetic error(say by dividing by zero) in a User Defined Function for a situation where in a stored procedure you would use RAISERROR or in code you...
2
by: Highlander416 | last post by:
This is driving me crazy. I need to create a UDF that would return a TRUE/FALSE (bit) value based on a comparison it does. CREATE FUNCTION dbo.SelectedByApplication ( @ApplicationID int,...
3
by: chreo | last post by:
I have user-defined function in MSSQL which returns Table (with 10 columns) (sorry for Polish names) CREATE FUNCTION PACZKI_Z_AKCJI (@AKCJA_ID int) RETURNS TABLE RETURN SELECT TOP 100...
4
by: Jack | last post by:
Hi, I am trying to run an example code from a book. However I am getting the following error message: Number: -2147217900 Description: Syntax error or access violation Source: Microsoft OLE...
2
by: Lalit Bhatia | last post by:
How can we call a sql server user defined function from C#? -- Regards, Lalit Bhatia
0
by: mongolian | last post by:
Hello, I am trying to execute an Extended Stored Procedure in a User Defined Function I wrote. It really is quite simple but I get an error saying "Only functions and extended stored procedures...
2
by: Mark B | last post by:
I have been able to retrieve the scalar value of a SQL Server Stored Procedure as follows: Shared Function fGetGroupPerformanceStatistic(ByVal strGroup As String) As String Dim sqlConnection1...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.