![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is this UNNEST function from an SQL standard, or is it something the PostgreSQL guys made up? I've googled a bit but been unable to find an answer. |
|
Whether it's standard or not, is it something which appears in other databases? I've googled, and it seems to be in DB2, but i can't tell if it's in Oracle or not, and i didn't see anything concerning any other database. |
#3
| |||
| |||
|
|
Tom Anderson<twic (AT) urchin (DOT) earth.li> writes: Is this UNNEST function from an SQL standard, or is it something the PostgreSQL guys made up? I've googled a bit but been unable to find an answer. It's a damned shame that the official SQL specification isn't online for public inspection and reference to quickly answer questions like that. |
|
The best I've been able to do is to see that PostgreSQL 8.4 docs have URL:http://www.postgresql.org/docs/8.4/s...-standard.html listing “S301 Enhanced UNNEST” as an unsupported feature from the standard. That strongly implies that UNNEST *is* specified in standard SQL, since the PostgreSQL 8.4 docs are noting that a specified enhancement is not available in their implementation. Whether it's standard or not, is it something which appears in other databases? I've googled, and it seems to be in DB2, but i can't tell if it's in Oracle or not, and i didn't see anything concerning any other database. You might have success looking for equivalent documentation to PostgreSQL's “Supported features” and “Unsupported features” lists in the corresponding documentation for each vendor's implementation. Your limit, then, is how well that information is documented; but I'd be surprised if, for example, Oracle's documentation doesn't have such a list. |
#4
| |||
| |||
|
|
On 2010-05-09 03:35, Ben Finney wrote: Tom Anderson<twic (AT) urchin (DOT) earth.li> writes: Is this UNNEST function from an SQL standard, or is it something the PostgreSQL guys made up? I've googled a bit but been unable to find an answer. It's a damned shame that the official SQL specification isn't online for public inspection and reference to quickly answer questions like that. Though not final, the late drafts are usually good enough: http://www.wiscorp.com/sql200n.zip Quote: This points to the documents which wlll likely be the documents that represent the SQL 2008 Standard. These documents are out for International Standard ballot at this time. The vote is an Up/Down vote. No changes allowed. |
|
There are references to the unnest operation in 5CD2-02-Foundation-2006-01.pdf, I did not check whether the usage in op's post conforms to those though. |
#5
| |||
| |||
|
|
FWIW, H2 doesn't support UNNEST. It does have something similar in the shape of a TABLE pseudo-function, which lets you create temporary tables inline, and into which you can substitute array parameters. In JDBC syntax: SELECT * FROM TABLE(x INTEGER = ?); You can put an array in as the parameter. Although H2 doesn't support the java.sql.Array type; you have to use a normal java array instead. And you can't use TABLE with IN; this: SELECT * FROM thing WHERE thing_id IN TABLE(selected_id INTEGER = ?); doesn't work. You have to rewrite it as a join: |
#6
| |||
| |||
|
|
On 2010-05-09 03:35, Ben Finney wrote: It's a damned shame that the official SQL specification isn't online for public inspection and reference to quickly answer questions like that. Though not final, the late drafts are usually good enough: http://www.wiscorp.com/sql200n.zip Quote: This points to the documents which wlll likely be the documents that represent the SQL 2008 Standard. These documents are out for International Standard ballot at this time. The vote is an Up/Down vote. No changes allowed. |
#7
| |||
| |||
|
|
[x-posted to comp.lang.java.programmer, since this is about JDBC and a java embedded database] For the benefit of cljp readers, UNNEST is an SQL-standard function which takes an array value and returns a table-like value, which you can use in join and IN conditions; i want it because i can use it to write queries that are like "select everything with an ID in this set". On Sun, 9 May 2010, Tom Anderson wrote: FWIW, H2 doesn't support UNNEST. It does have something similar in the shape of a TABLE pseudo-function, which lets you create temporary tables inline, and into which you can substitute array parameters. In JDBC syntax: SELECT * FROM TABLE(x INTEGER = ?); You can put an array in as the parameter. Although H2 doesn't support the java.sql.Array type; you have to use a normal java array instead. And you can't use TABLE with IN; this: SELECT * FROM thing WHERE thing_id IN TABLE(selected_id INTEGER = ?); doesn't work. You have to rewrite it as a join: Correction - you can also whip up a closer approximation of UNNEST, which can be used in an IN clause, by hand: SELECT * FROM thing WHERE thing_id IN (SELECT ARRAY_GET(?1, X) AS selected_id FROM SYSTEM_RANGE(1, ARRAY_LENGTH(?1))); (the AS is unnecessary but informative) That makes a 100% genuine subquery, so i'd be optimistic about the query planner doing something sensible here. |
#8
| |||
| |||
|
|
How does that organisation get ahold of those documents? |
|
What is the difference in copyright license between these “late drafts” and the final specification? If an arbitrary person were to redistribute the drafts, is that a violation of the copyright? |
|
My understanding is that SQL 2011 drafts are currently being discussed. Are they likely to be made available also, and what is the copyright status of them? |
![]() |
| Thread Tools | |
| Display Modes | |
| |