473,396 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,396 software developers and data experts.

Using Array content in IN expression

Is it possible in the new DB2 9.5 to use the content of an array in an
IN expression?

Say we have the ddl:

CREATE TYPE Numbers AS Integer ARRAY[];

CREATE tab1 AS (
id integer,
numbers Numbers
);

CREATE tab2 AS (
id integer
);
Is such SQL possible:

SELECT tab2.* FROM tab2 WHERE tab2.id IN (SELECT numbers FROM tab1
WHERE id = 12)

And are the semantics, that it will match all rows from tab2 where the
id is contained in the numbers array from tab1?

Regards,
Janick
Jan 8 '08 #1
8 8849
ja******@swissasp.ch wrote:
Is it possible in the new DB2 9.5 to use the content of an array in an
IN expression?

Say we have the ddl:

CREATE TYPE Numbers AS Integer ARRAY[];

CREATE tab1 AS (
id integer,
numbers Numbers
);

CREATE tab2 AS (
id integer
);
Is such SQL possible:

SELECT tab2.* FROM tab2 WHERE tab2.id IN (SELECT numbers FROM tab1
WHERE id = 12)

And are the semantics, that it will match all rows from tab2 where the
id is contained in the numbers array from tab1?
IN (SELECT numbers FROM (UNNEST(numberarray)) AS X(numbers)

Now, ARRAYs are supported in stored procedures only.
No column type.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 8 '08 #2
db2
This is a frequently used query.
I think upgrading to 9.5 might need lot of code changes.
Thanks,
Joseph
http://db2examples.googlepages.com
On Jan 9, 3:41*am, Serge Rielau <srie...@ca.ibm.comwrote:
jaber...@swissasp.ch wrote:
Is it possible in the new DB2 9.5 to use the content of an array in an
IN expression?
Say we have the ddl:
CREATE TYPE Numbers AS Integer ARRAY[];
CREATE tab1 AS (
* id integer,
* numbers Numbers
);
CREATE tab2 AS (
* id integer
);
Is such SQL possible:
SELECT tab2.* FROM tab2 WHERE tab2.id IN (SELECT numbers FROM tab1
WHERE id = 12)
And are the semantics, that it will match all rows from tab2 where the
id is contained in the numbers array from tab1?

IN (SELECT numbers FROM (UNNEST(numberarray)) AS X(numbers)

Now, ARRAYs are supported in stored procedures only.
No column type.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab- Hide quoted text -

- Show quoted text -
Jan 9 '08 #3
IN (SELECT numbers FROM (UNNEST(numberarray)) AS X(numbers)
>
Now, ARRAYs are supported in stored procedures only.
No column type.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Ok, but I could use this in static SQL like

SELECT * FROM tab1 WHERE col1 IN (SELECT numbers FROM
(UNNEST(:numberarray)) AS X(numbers)

where numbearray would be a host-variable (in java, say)?
Because this would be really cool, as right now, we often pass a set
of ids as a string to a stored procedure and then have to create
dynamic sql like

String sql = "SELECT * FROM tab1 WHERE col1 IN ("+ids+") ";

Regards,
Janick
Jan 10 '08 #4
ja******@swissasp.ch wrote:
>IN (SELECT numbers FROM (UNNEST(numberarray)) AS X(numbers)

Now, ARRAYs are supported in stored procedures only.
No column type.
Ok, but I could use this in static SQL like

SELECT * FROM tab1 WHERE col1 IN (SELECT numbers FROM
(UNNEST(:numberarray)) AS X(numbers)
No. Stored procedures and CALL statements for now.
Feel free to submit a feature request.
Generalizing Java support would actually be quite simple I believe...

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 10 '08 #5
On 10 Jan., 23:03, Serge Rielau <srie...@ca.ibm.comwrote:
jaber...@swissasp.ch wrote:
IN (SELECT numbers FROM (UNNEST(numberarray)) AS X(numbers)
Now, ARRAYs are supported in stored procedures only.
No column type.
Ok, but I could use this in static SQL like
SELECT * FROM tab1 WHERE col1 IN (SELECT numbers FROM
(UNNEST(:numberarray)) AS X(numbers)

No. Stored procedures and CALL statements for now.
Feel free to submit a feature request.
Generalizing Java support would actually be quite simple I believe...

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thx for the Info. How would I submit a feature request? Through ESR?

Regards,
Janick
Jan 10 '08 #6
ja******@swissasp.ch wrote:
On 10 Jan., 23:03, Serge Rielau <srie...@ca.ibm.comwrote:
>jaber...@swissasp.ch wrote:
>>>IN (SELECT numbers FROM (UNNEST(numberarray)) AS X(numbers)
Now, ARRAYs are supported in stored procedures only.
No column type.
Ok, but I could use this in static SQL like
SELECT * FROM tab1 WHERE col1 IN (SELECT numbers FROM
(UNNEST(:numberarray)) AS X(numbers)
No. Stored procedures and CALL statements for now.
Feel free to submit a feature request.
Generalizing Java support would actually be quite simple I believe...
Thx for the Info. How would I submit a feature request? Through ESR?
I don't know the acronym...
Do you have an IBM rep?

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 11 '08 #7
I don't know the acronym...
Do you have an IBM rep?

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
ESR is the support service, where you can create PMRs.

No, I don't think we have any IBM representative (I suppose this is
what rep means? :)).

Regards,
Janick
Jan 13 '08 #8
ja******@swissasp.ch wrote:
>I don't know the acronym...
Do you have an IBM rep?
ESR is the support service, where you can create PMRs.
OK. Logging a PMR for a feature request leaves a track record.
Now, please don't expect you get the feature because you alone ask for it.
We'll see if there are more requests coming in and prioritize
accordingly as customers start picking up usage.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 14 '08 #9

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

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
12
by: natkw1 | last post by:
Hi, I'm attempting to understand the use of pointers(at least grasp how pointers work). I've read the FAQ on http://www.eskimo.com/~scs/C-faq/s6.html on pointers and arrays but I'm still a bit...
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
13
by: Kantha | last post by:
Hi all, I have declared an Union as follows typedef union { struct interrupt_bits { unsigned char c_int_hs_fs_status : 1, c_setup_intflag : 1,
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
9
by: Srinu | last post by:
Hi All, We know the following facts, 1. A two dimentional arrays in C is stored similar to a single dimentional array. 2. * is the dereference operator that gives value at address denoted by...
1
by: skezzolo | last post by:
Hi Everyone. $layout=ereg_replace("\+)\]\]", $dillo, $layout); I'm trying to use the result of a Regular Expression Match as an Index for the Associative Array $Dillo, so that the to-replace...
0
by: Konrad | last post by:
Hi everyone. I've got problem with converting xml file to xsd schema. The Xml file looks like: <?xml version="1.0" encoding="iso-8859-2"?> <rss version="2.0"...
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: 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
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...
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
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,...

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.