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

Use of SELECT [Fields] INTO [var] in UDFs

Hi,

I have a problem creating the function below:
CREATE FUNCTION TaskProgress (
PROJETO VARCHAR(10),
REVISAO VARCHAR(4),
TAREFA VARCHAR(12)
)
RETURNS DECIMAL(5,2)
LANGUAGE SQL
MODIFIES SQL DATA
NOT DETERMINISTIC
NO EXTERNAL ACTION
SPECIFIC TaskProgress
BEGIN ATOMIC
--------------------------------------------------------------------------------------
-- DECLARACAO DE VARIAVEIS DA FUNCAO --
--------------------------------------------------------------------------------------
DECLARE iResult DECIMAL(5,2) DEFAULT 0;
DECLARE nQtdTot DOUBLE DEFAULT 0;
DECLARE nQtd DOUBLE DEFAULT 0;
--------------------------------------------------------------------------------------
-- PROCURA QTD PLANEJADA NAS TAREFAS --
--------------------------------------------------------------------------------------
SELECT AF9.AF9_QUANT
INTO nQtd
FROM AF9010 AF9
WHERE AF9.AF9_PROJET = PROJETO AND
AF9.AF9_REVISA = REVISAO AND
AF9.AF9_TAREFA = TAREFA AND
AF9.D_E_L_E_T_ <> '*';
--------------------------------------------------------------------------------------
-- CALCULA PERCENTUAL EXECUTADO --
--------------------------------------------------------------------------------------
SET iResult = Round( ( nQtd / nQtdTot ) * 100, 2);
RETURN iResult;
END

The error message when i try to create this function is : "DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: nQtd;INTO;<space>
Message: An unexpected token "nQtd" was found following "INTO". Expected tokens may include: "<space>".
Line: 23"

I guess this is related to the use of SELECT [field] INTO [var] construction for my SQL statement. I checked some DB2 documentation and didnīt find any issues related to the use of this kind of statement.

Could anybody help me to find what i am doing wrong?

Hugs
Aug 22 '07 #1
0 985

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

Similar topics

5
by: johkar | last post by:
This script works fine if all form fields have one value, but what do you do if one of the form fields was a multiple select? Example: status=blue&status=red function getParams() { var...
3
by: Shawn Modersohn | last post by:
I've got <form name="form1> <select name="select1"> <option value="null" selected>Select A Team</option> <option value="Cougars">Cougars</option> <option value="Mavericks">Mavericks</option>...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
7
by: Rhino | last post by:
I am updating some Java UDFs from DB2GENERAL to DB2JAVA as suggested in the manuals for DB2 Version 8 but I'm having problems with setSQLstate() and setSQLmessage(). If I'm reading the manuals...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
5
by: Bubba | last post by:
I have a dynamic pulldown list (ASP with javascript) that when a user picks a state, the corresponding counties for that state appear in a dynamic second pulldown list. When I submit the form, the...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.