For example:
select Column1, NULL as Alias1 from table1
union
select Column1, Column2 as Alias1 from table2
results in the following error message:
"NULL " is not a column in an inserted table, updated table, or any
table identified in a FROM clause
I could resort to using the NULLIF function, but that seems sort of dirty.
Surely I am just not supplying the correct syntax.
Thanks in advance for any help,
Jeff Hartley
First Lastname <first.l...@worldspan.com> wrote in message
news:7ur19a$c4q$1...@ssauraaa-i-1.production.compuserve.com...
Any ideas?
S. J. Cross <s...@nospam.ibm.net> wrote in message
news:38116...@news3.prserv.net...
If the data type of the null column is not important, you can replace the
NULL in your SELECT statement with a CAST of the NULL to an arbitrary data
type value: e.g., CAST(NULL as INTEGER). But if you are doing a join, the
data types of the corresponding columns in the different tables must, of
course, be compatible. Hope this helps/makes sense.
Jeff Hartley <jeff.h...@ga.prestige.net> wrote in message
news:s14sni...@corp.supernews.com...
NULL is a somewhat special keyword, it can only occur in certain places.
The reason is that NULL is by definition untyped.
So you have to cast it:
CAST(NULL AS <type>) AS Alias1
Cheers
Serge
select cast(NULL as smallint) from sysibm.sysdummy1
SQL0199N The use of the reserved word "AS" following "" is not valid.
Expected tokens may include: ") , ". SQLSTATE=42601
Any ideas?
thanks,
jeff
Uhm - maybe - "sysdummy1" smells like you are using a bigger box (DB2
AS/400 ?)
They might have added that later than DB2 UDB for Unix et al.
Cheers
Serge
I am using DB2 OS/390 5.1.1 Has anyone used the cast function with this
version?
thanks,
jeff
Serge Rielau <sri...@ca.ibm.com> wrote in message
news:3814B22D...@ca.ibm.com...
Try expression CAST(NULL AS <TYPE>) AS Alias1.
--
___________ (R)
/_ _______ Adam Płaszczyca (+48 601) 829697
___/ /_ ___ ul. Jagiellońska 62 m 120, 03-468 Warszawa
_______/ /_ IRC: _555, http://www.waw.pdi.net/~trzypion/
___________/ mail: _5...@irc.pl UIN: 4098313