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

Is this legal db2 sql ???

i have a udf that returns a table i then want to set a variable in
using a select on the returned table :

an example (not the real code)..
..
..
..

declare count_t int;

set count_t = (
with TABLEA(col1) as ( select token from table(udf(arg1,arg2) ) as
sp where token is not null)
select count(*) from TABLEA;
);

but i get this error :
sql21043n : The command processed as an sql statement because it was
not a valid command line processor command. during sql processing it
returned : sql0104N an unexpected token "as" was found "
any ideas of how to do this?

thanks in advance.

--annand

Sep 20 '06 #1
3 1525
an******@hotmail.com wrote:
i have a udf that returns a table i then want to set a variable in
using a select on the returned table :

an example (not the real code)..
.
.
.

declare count_t int;

set count_t = (
with TABLEA(col1) as ( select token from table(udf(arg1,arg2) ) as
sp where token is not null)
select count(*) from TABLEA;
);

but i get this error :
sql21043n : The command processed as an sql statement because it was
not a valid command line processor command. during sql processing it
returned : sql0104N an unexpected token "as" was found "
WITH is only allowed in SELECT _STATEMENT_ and the query feeding an
INSERT. What you have there is a scalar subquery.
This has nothing to to with the table function.

SET count = (SELECT COUNT(*) FROM TABLE(udf(arg1, arg2)) AS F)
should work
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Sep 20 '06 #2
set count_t = (
with TABLEA(col1) as ( select token from table(udf(arg1,arg2) ) as
sp where token is not null)
select count(*) from TABLEA;
Where did token come from? Expressions or renamed column names appeas
only in select list cannot use in where clause.
SET count = (SELECT COUNT(*) FROM TABLE(udf(arg1, arg2)) AS F)
This count(*) will include rows which token is null.
I think it is necessary to add "where token is not null".
Or
SET count = (SELECT COUNT(token) FROM TABLE(udf(arg1, arg2)) AS F)

Sep 20 '06 #3
Tonkuma wrote:
set count_t = (
with TABLEA(col1) as ( select token from table(udf(arg1,arg2) ) as
sp where token is not null)
select count(*) from TABLEA;
Where did token come from? Expressions or renamed column names appeas
only in select list cannot use in where clause.
That's most probably a column returned by the table function. Since those
columns were not explicitly named in the above statement, DB2 picks the
names used in the CREATE FUNCTION statement.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 21 '06 #4

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

Similar topics

1
by: pakkocool | last post by:
¿Como ganar dinero en internet? Lee atentamente el siguiente texto, es super interesante y te hara ganar muchos dolares si sigues las instrucciones y le pones empeño: Hace unos días que...
3
by: Chris Johnson | last post by:
Greetings all: I come across an interesting question (to me anyway) and I do not know the answer. Code/Questions follow: #include <iostream> #if 0 // uncommenting *should* make call...
7
by: Nice | last post by:
Hi. I read somewhere that in XML the tag <xml> is not legal. But in W3C specs I can't find this statement. Does anyone know about it ?
0
by: mykidisgollum | last post by:
Greetings, I have code which prints a document who's attributes are saved as flags in a database. One of the those attributes is letter or legal. When I am printing, I use the following...
7
by: __PPS__ | last post by:
Actually what I mean is that - if I have some memory buffer, lets say char a; and then I do like this: DWORD num = 0x1234; *(DWORD*)a = num; (1) *(DWORD*)(a+1) = num; (2) either...
6
by: aj | last post by:
I currently have 2 official DB2 Workgroup Edition licenses for my 2 v8 production servers. I also have tech support/software upgrade agreements in place for both servers. I am interested in...
2
by: Thomas Paul Diffenbach | last post by:
I'm trying to write a space efficient string (nul terminated array of char), storing the characters directly unless the number of characters is too large to be so stored, and storing a pointer to...
1
by: Wiktor Zychla | last post by:
is it legal to distribute axshdocvw, shdocvw and mshtml.dll with my application? is it legal to distribute Microsoft.mshtml.dll from 'Primary Interop Assemblies' folder (I assume it comes with...
11
by: Alberto Giménez | last post by:
Hi, I've seen some object oriented programming bits out there and i'm not sure if they're legal. For example: struct Object { int field1; int field2; }; struct SubObject { int field1; /*...
2
by: Army1987 | last post by:
Is this program legal C89? /* no headers included */ int main(void) { if (sizeof (exit(0), 0), ((void (* )(int))&exit)( (puts((const char *)"hello, world"), 0) ), 0) {
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
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
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
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.