473,881 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OUTER UNION

Hello,

While looking into a particular SQL statement which seemed to put the
database under pressure, I found the following construct which is new to
me:

SELECT ...
FROM ...
OUTER UNION
SELECT ...
FROM ...

The statement was seen in the "Dynamic SQL statement text" part of "GET
SNAPSHOT FOR APPLICATION". In other words: The construct was accepted by
DB2. OUTER UNION doesn't seem to part of the SQL standard, and I can't
find documentation for it in DB2's documentation. Is this a documentation
defect, or is it simply me who's not good enough at searching the docs?

(The statement was issued from a SAS script, probably part of a SAS "proc
sql" section. OUTER UNION is documented in SAS' docs. I want to make sure
that SAS and DB2 agree on what's going on.)

--
Regards,
Troels Arvin <tr****@arvin.d k>
http://troels.arvin.dk/
Aug 5 '08 #1
10 5645
Troels Arvin wrote:
Hello,

While looking into a particular SQL statement which seemed to put the
database under pressure, I found the following construct which is new to
me:

SELECT ...
FROM ...
OUTER UNION
SELECT ...
FROM ...

The statement was seen in the "Dynamic SQL statement text" part of "GET
SNAPSHOT FOR APPLICATION". In other words: The construct was accepted by
DB2. OUTER UNION doesn't seem to part of the SQL standard, and I can't
find documentation for it in DB2's documentation. Is this a documentation
defect, or is it simply me who's not good enough at searching the docs?

(The statement was issued from a SAS script, probably part of a SAS "proc
sql" section. OUTER UNION is documented in SAS' docs. I want to make sure
that SAS and DB2 agree on what's going on.)
db2 =connect to test;

Database Connection Information

Database server = DB2/NT 9.X.0
SQL authorization ID = SRIELAU
Local database alias = TEST

db2 =values 1 outer union values 1;
SQL0104N An unexpected token "outer" was found following "values 1 ".
Expected tokens may include: "<space>". SQLSTATE=42601
db2 =values 1 union values 1;

1
-----------
1

1 record(s) selected.
Which platform are you on? I have never heard of it. What would be it's
semantics?

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 5 '08 #2
Serge Rielau wrote:
db2 =values 1 outer union values 1; SQL0104N An unexpected token
"outer" was found following "values 1 ". Expected tokens may include:
"<space>". SQLSTATE=42601 db2 =values 1 union values 1;

1
-----------
1

1 record(s) selected.
Which platform are you on?
DB2 v. 8 on AIX and DB2 v. 9.5 on Linux. On these platforms, your test
with VALUES ... VALUES also results in an error. But if I use real test
tables, "outer union" is accepted. It seems DB2 simply ignores the "outer"
word.

I have never heard of it. What would be it's semantics?
http://v8doc.sas.com/sashtml/proc/zueryexp.htm has some examples of it. If
my reading of SAS' docs is right, the semantics of SAS' OUTER UNION is
certainly not to simply ignore the OUTER word. SAS is surely being strange
regarding this (as it is with heaps of other subjects), but so is DB2: Why
doesn't it protest?

--
Regards,
Troels Arvin <tr****@arvin.d k>
http://troels.arvin.dk/
Aug 5 '08 #3
Troels Arvin wrote:
Serge Rielau wrote:
>db2 =values 1 outer union values 1; SQL0104N An unexpected token
"outer" was found following "values 1 ". Expected tokens may include:
"<space>". SQLSTATE=42601 db2 =values 1 union values 1;

1
-----------
1

1 record(s) selected.
Which platform are you on?

DB2 v. 8 on AIX and DB2 v. 9.5 on Linux. On these platforms, your test
with VALUES ... VALUES also results in an error. But if I use real test
tables, "outer union" is accepted. It seems DB2 simply ignores the "outer"
word.

>I have never heard of it. What would be it's semantics?

http://v8doc.sas.com/sashtml/proc/zueryexp.htm has some examples of it. If
my reading of SAS' docs is right, the semantics of SAS' OUTER UNION is
certainly not to simply ignore the OUTER word. SAS is surely being strange
regarding this (as it is with heaps of other subjects), but so is DB2: Why
doesn't it protest?
Oh!, Ohh!

SELECT outer.c1 FROM T OUTER UNION VALUES 1;

:-)

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 5 '08 #4
The OUTER UNION is part of the infixed JOINs we define4d in SQL-99.
Nobody uses it,but it was easy to define, so it got into the
Standards. It can stick two totally unrelated tables together
blindly.

http://www2.sas.com/proceedings/sugi31/242-31.pdf
Aug 6 '08 #5
--CELKO-- wrote:
The OUTER UNION is part of the infixed JOINs we define4d in SQL-99.
I can't find it in the draft for SQL:200n. Where in the SQL:1999 standard
is it mentioned?

--
Regards,
Troels Arvin <tr****@arvin.d k>
http://troels.arvin.dk/
Aug 7 '08 #6
Troels Arvin wrote:
--CELKO-- wrote:
>The OUTER UNION is part of the infixed JOINs we define4d in SQL-99.

I can't find it in the draft for SQL:200n. Where in the SQL:1999 standard
is it mentioned?
Troels,

Did you see my post? DB2 interpretes the OUTER as a table alias.
T AS OUTER.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 7 '08 #7
Serge Rielau wrote:
Oh!, Ohh!

SELECT outer.c1 FROM T OUTER UNION VALUES 1;
This was what I thought initially, as well (potentially very much
different from what the user expects after reading SAS' docs). But I've
seen OUTER UNION work with three different tables:

SELECT ...
FROM ...
OUTER UNION
SELECT ...
FROM ...
OUTER UNION
SELECT ...
FROM ...

Would DB2 allow re-use of table aliases?

--
Regards,
Troels Arvin <tr****@arvin.d k>
http://troels.arvin.dk/
Aug 7 '08 #8
Troels Arvin wrote:
Would DB2 allow re-use of table aliases?
Yes, just try:
SELECT * FROM T AS X
UNION
SELECT * FROM T AS X
UNION
SELECT * FROM T AS X

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 8 '08 #9
On Aug 7, 2:19*pm, Troels Arvin <tro...@arvin.d kwrote:
--CELKO-- wrote:
The OUTER UNION is part of the infixed JOINs we define4d in SQL-99.

I can't find it in the draft for SQL:200n. Where in the SQL:1999 standard
is it mentioned?
I cant find it either and Mimers SQL Validator (http://
developer.mimer .com/validator/) doesn't recognize the construct.
CORRESPONDING is a reserved word though, but it where reserved back in
SQL92.
/Lennart
Aug 8 '08 #10

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

Similar topics

1
11702
by: Dave | last post by:
Hi I have the following 4 tables and I need to do a fully outerjoin on them. create table A (a number, b number, c char(10), primary key (a,b)) create table B (a number, b number, c char(10), primary key (a,b)) create table C (a number, b number, c char(10), priamry key (a,b)) create table D (a number, b number, c char(10), priamry key (a,b)) In oracle 9i, the following query returns correct results set, if I were to
1
17032
by: Rahul Khandpur | last post by:
hi friends, i have one query related to oracle9i outer join condition it is mentioned that we can't use (+) with the operand of OR and IN operators example select e.last_name,e.department_id,d.department_name,d.department_id from employees e , departments d
7
6241
by: alexcn | last post by:
I have the following query: SELECT dbo.tSymExch.exCode, dbo.tSymGrp.sgCode, dbo.tSymMain.smCode FROM dbo.tSymExch FULL OUTER JOIN dbo.tSymGrp ON dbo.tSymExch.exID = dbo.tSymGrp.sgexID FULL OUTER JOIN dbo.tSymMain ON dbo.tSymGrp.sgID = dbo.tSymMain.smsgID Which produces:
4
7856
by: KT | last post by:
This might not be possible, but on the chance that it can - is there a way to do the following: Given a arbitray one dimesional value list: ('AALGX','12345','XXXXX','AAINX','AMMXX') Is there a way that I could do a select statement, or similiar, in the value list, to get the following result field_name
3
5736
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int pointing to the sentence they come from (a column called "regret"). I also have a table of stop words (called "GenericStopWords") that contains the words I do not want to consider. That table has a single column called "word". I started off using a...
5
12963
by: Randy Harris | last post by:
Using an outer join, a query can return all records from Table1 and only those matching from Table2 (or vice versa). How can I write a query that will return unmatched records from both sides? For example: Table1 Key Data ---------- 123 Bill 124 Tom 125 Joe
6
2191
by: PW | last post by:
I've created an ASP application which uses an Access database. I've created an outer join query, but for some reason the "Property_Def" column is not aligning with the "ESPN" column. They should be aligned on the ESPI common columns. In this attached image, the first lines ESPI of 010471 "ADJUSTABILITY" which should line up with the "Property_Def" column that says "An indication of whether or not the item is adjustable".
5
3136
by: gimme_this_gimme_that | last post by:
I have an employee table with two columns, one named login, the other named otherdata. I have a list of login values, some of which do not exist in the employee table. I want to fetch the data in the employee.otherdata column and return nulls when there is no match. ....
0
1582
by: Hamayun Khan | last post by:
Hi All I am using the following query to select records from two tables. Select JobTitle,JobDesc,Scraped,logoimage,JobPostID,SchoolID,web,MemType,InstitutionName,PayScale,LEA,Contract as ContractType,HoursAbl,StartDate,ClosingDate,asap from tblJobScrap Union ( SELECT tblJobPost.JobTitle,tblJobPost.JobDesc,Scraped,tblSchools.logoimage,tblJobPost.JobPostID,tblJobPost.SchoolID,tblSchools.web,cast(tblJobPost.MemType as nvarchar(255)) as...
0
9926
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9776
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11095
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10812
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9552
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7108
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.