473,549 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1535
an******@hotmai l.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
4266
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 estoy buscando la forma de ganar algún dinero más extra, a parte del que gano por navegar en Internet. Para ello recorro grupos de noticias, tablones,...
3
2202
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 ambigous because of // odering deduction of the function signature,
7
2149
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
1258
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 code, which is the ONLY way I could come up with to reliably print to legal paper, assuming a default of letter. There HAS to be a better way. I'm...
7
4347
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 (1) or (2) will assign dword value to not dword aligned address. The question is - will this code be fatal on some systems??
6
4043
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 building a separate backup/test DB2 server upon which I can experiment with impunity. This backup server will not be in production in any way, and...
2
3707
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 other storage otherwise. Rather than lose space to padding by just using a sentinal bool to indicate which member of the union has been written...
1
2522
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 Visual Studio)? thanks for any clues, Wiktor Zychla
11
2033
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; /* the same as Object */
2
1671
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) {
0
7471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7985
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5111
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3496
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
784
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.