473,396 Members | 1,760 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.

Function(UDF) Problem

Hi All,

I have a small function below, when i try to create this, it says the
following 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:
SQL0104N An unexpected token "VARYING" was found following
"RESULT_SET_LOCATOR". Expected tokens may include: "<space>". LINE
NUMBER=26. SQLSTATE=42601.

As this function i have to use in select statement(like select
empno,call_accountlist...), so i cant create this as procedure. Can
anyone help me out in this? where is the problem?
CREATE function CALL_AccountList ()
RETURNS INTEGER
LANGUAGE SQL

BEGIN ATOMIC

DECLARE sqlcode INT DEFAULT 0;
DECLARE v_empId INT DEFAULT 0;
DECLARE v_empNum INT DEFAULT 0;
DECLARE v_empCnt INT DEFAULT 0;
DECLARE loc1 RESULT_SET_LOCATOR VARYING;
SET v_empNum =20;
CALL AccountList('BA',307);
ASSOCIATE RESULT SET LOCATOR(loc1)WITH
PROCEDURE AccountPackage.AccountList;
ALLOCATE c1 CURSOR FOR RESULT SET loc1;
L1:LOOP
FETCH FROM c1 INTO v_empID;
IF (sqlcode =100)or (v_empCnt >v_empNum)
THEN LEAVE L1;
ELSE
SET v_empCnt =v_empCnt +1;
INSERT INTO temp_table (num_col,char_col)
VALUES (v_empId,'IN DEPARTMENT ');
END IF;
END LOOP L1;
RETURN v_empCnt;
END@

Thanks in Advance,
Praveen
Nov 12 '05 #1
1 1488
Praveen,

SQL Functions use inline SQL PL as described in Compound SQL (Dynamic).
The SQL PL you used there is well beyond it's capabilities.
You have four possible routes of action:
1. Use an SQL Procedure instead of an SQL Function
2. Same as 1. but in addition write an C Function which CALLs the stored
procedure.
3. Write a C or Java function instead of an SQL Function
4. Same as 1. but in addition dowload the DB2 Stinger Technology Preview
and write an SQL Function that CALLs the stored procedure.
DB2 Stinger supports CALL in inline SQL PL, but it does not support
resultset support in inline SQL PL.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: rcb845 | last post by:
Hi everybody of the PHP community, I am using the php function "getimagesize()" to access the width/height of an image from the Web. This function should return false if image is not available....
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
3
by: Tomaz Rotovnik | last post by:
Hi I created very simple dll (vc++) which has three functions (start, stop and initialization). it starts capturing sound from soundblaster and when the buffer is filled with the data, dll calls...
5
by: Ian Davies | last post by:
Dear Access expert I am trying to use an mde application developed in Access2k with Access 2002. I get an Access error box: Function is not available.. Date() etc. Is Access 2002 back...
8
by: Mantorok Redgormor | last post by:
I have ran into a problem where I have a struct that has a member which contains a pointer to function and is initialized to a function in the initializer list. With my array of structs of this...
1
by: Nacho | last post by:
Hello.. I have one problem with my reusable function to validate date.. I want to use this function to all my web project no validate date, but It's works fine if I have one textbox to...
3
by: dice | last post by:
Hi, In order to use an external api call that requires a function pointer I am currently creating static wrappers to call my objects functions. I want to re-jig this so I only need 1 static...
3
by: ryan.mitchley | last post by:
Hi all I have a class (cPort) that is designed to receive objects and, depending on the type, call a handler (callback) in any descendant of a cProcessBlock class. Callback functions take a...
10
by: Constantine AI | last post by:
Hi i am having a little problem with an equation function that was created from all your help previously. The function works fine itself but with a small glitch within it. Here is the function...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.