473,387 Members | 1,504 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,387 software developers and data experts.

Cursor in UDF

I am on: Database server = DB2/AIX64 8.1.5
It is also a partitioned database.

I am trying to create an UDF that uses cursors. The following is a
simplified version of my UDF and error given.

create function testFunction(inString varchar(4000))
returns varchar(4000)
deterministic
no external action
reads sql data

F1: begin atomic

declare newString, orgCName varchar(4000);
declare len int;

declare workString varchar(4000);

declare orgCursor cursor for
select organisation_translation
from thomas.organisation_translation
where code= workString for read only;

if inString is null
then
return null;
end if;

set workString = rtrim(ltrim(inString));

-- Check whether the name exists in the database.
open orgCursor;
fetch orgCursor into orgCName;
close orgCursor;

return orgCName;

end F1@

[IBM][CLI Driver][DB2/AIX64] SQL0104N An unexpected token "for" was
found following "are orgCursor cursor". Expected tokens may include:
"<SQL_variable_condition_declaration>". LINE NUMBER=1.
SQLSTATE=42601

Where am I going wrong on this. I have read every post pertaining to
UDFs and have not found the answer.

Thanks in advance,
Thomas
Nov 12 '05 #1
2 2933
Who needs cursors? (if needed you can use FOR)
create function testFunction(inString varchar(4000))
returns varchar(4000)
deterministic
no external action
reads sql data

RETURN (select organisation_translation
from thomas.organisation_translation
where code= workString for read only)

Cheres
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Serge Rielau wrote:
Who needs cursors? (if needed you can use FOR)
create function testFunction(inString varchar(4000))
returns varchar(4000)
deterministic
no external action
reads sql data


RETURN (select organisation_translation
from thomas.organisation_translation
where code= workString for read only)

Cheres
Serge

Without the FOR RED ONLY of course

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

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

Similar topics

3
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting...
5
by: Vlad Simionescu | last post by:
Hello I'm trying to let my Windows Form application perform a lengthy operation while displaying a progress bar in a modal dialog window; the dialog has a cancel button. The dialog is displayed...
2
by: dave | last post by:
In my form Ive got a SaveData() routine that saves changes to a DB. When I encounter an exception in the save operations, I am having trouble chaning the cursor back to the default cursor, it just...
5
by: Lespaul36 | last post by:
I have a mdi app. I need to change the cursor when I click on certain button on a form that I made into a toolbar. I tried to use cursor.current. But the cursor won't show. if I change the form...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
2
by: Alex | last post by:
In the code below, clicking on the button ButtonChangeCursor changes the form's cursor to a WaitCursor. Clicking the button ButtonRestoreCursor changes the form's cursor back to its original...
2
by: Jim Frazer | last post by:
Hi, I'm working on an application in C# that will allow the user to create simple CAD drawings on a CEPC system. I would like to be able to change the cursor shape depending on the drawing mode...
7
by: Academic | last post by:
What are the different effects of the following two statements: C1.Cursor = Cursors.WaitCursor C1.Cursor.Current = Cursors.WaitCursor I believe the first replaces the entire C1.Cursor...
0
debasisdas
by: debasisdas | last post by:
RESTRICTIONS ON CURSOR VARIABLES ================================= Currently, cursor variables are subject to the following restrictions: Cannot declare cursor variables in a package spec. ...
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.