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

Strange results, playing with table function

Hello, all.

DB2 vv8.2.7, 9.1.3a, 9.5

Here is a simple table function returning sequence of i (this is a
parameter) rows with one column of int values from 1 to i:

--- interval start ---
create function interval(i int)
returns table(n int)
language sql
deterministic
no external action
return
with t (n) as (
values 1
union all
select n+1
from t
where n<i
)
select n from t;
--- interval end ---

Can someone describe results of these select statements, especially 1-
st one that retruns only 1 row instead of 5 rows expected:

1.
SELECT N
FROM TABLE(INTERVAL(5)) T
WHERE N IN (SELECT T2.N FROM TABLE(INTERVAL(T.N)) T2);

2.
SELECT N
FROM TABLE(INTERVAL(5)) T
WHERE EXISTS (SELECT 1 FROM TABLE(INTERVAL(T.N)) T2 WHERE T2.N=T.N);

Regards,
Mark B.
Dec 18 '07 #1
1 1405
4.****@mail.ru wrote:
Hello, all.

DB2 vv8.2.7, 9.1.3a, 9.5

Here is a simple table function returning sequence of i (this is a
parameter) rows with one column of int values from 1 to i:

--- interval start ---
create function interval(i int)
returns table(n int)
language sql
deterministic
no external action
return
with t (n) as (
values 1
union all
select n+1
from t
where n<i
)
select n from t;
--- interval end ---

Can someone describe results of these select statements, especially 1-
st one that retruns only 1 row instead of 5 rows expected:

1.
SELECT N
FROM TABLE(INTERVAL(5)) T
WHERE N IN (SELECT T2.N FROM TABLE(INTERVAL(T.N)) T2);

2.
SELECT N
FROM TABLE(INTERVAL(5)) T
WHERE EXISTS (SELECT 1 FROM TABLE(INTERVAL(T.N)) T2 WHERE T2.N=T.N);
I think I know what this is....
Anyway it's clearly a bug. Can you open a PMR to get an APAR?

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Dec 18 '07 #2

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

Similar topics

0
by: Soefara | last post by:
Dear Sirs, I am experiencing strange results when trying to optimize a LEFT JOIN on 3 tables using MySQL. Given 3 tables A, B, C such as the following: create table A ( uniqueId int not...
7
by: Anon Email | last post by:
Hi people, I'm playing around with Bartosz Milewski's code at the moment, and I got the following strange results upon execution of the code included further below. Please be aware that I...
3
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. ...
9
by: Wescotte | last post by:
Here is a small sample program I wrote in PHP to help illustrates problem I'm having. The data base is using DB2 V5R3M0. The client is WinXP machine using the iSeries Client Access Driver ver...
1
by: dschectman | last post by:
I have a page with two dynamic tables. One is a master list of items for selection. The second is a list of selected items. The master list contains 4 columns. 1) The item code - hidden For...
0
by: Wescotte | last post by:
<?php global $TABLE_GL_DATA; global $connect; $PREPARED_SQL = odbc_prepare($connect, "INSERT INTO $TABLE_GL_DATA VALUES (?,?,?,?,?,?,?)"); function Generate_GL_Data() {
11
by: Dagwood Bumstead | last post by:
I play around with js a little... I just don't get this. The file below is just trying out some things... it does exactly what I want (hides/displays some things, no big deal) The problem is...
5
by: BillCo | last post by:
I'm having a problem with a union query, two simple queries joined with a union statement. It's created in code based on parameters. Users were noticing some inconsistant data and when I analysed...
1
by: russot00 | last post by:
I have 3 drop down menus that are used in a search to locate restaurants in a db. All of the drop down menus function, a search can be submitted with any combination of drop downs and the results are...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.