467,189 Members | 1,298 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,189 developers. It's quick & easy.

Select null as xyz from sysibm.sysdummy1

Hi,

Why is it that this command doesn't work in DB2.
I have to create a view in which one of the columns has to be
null(Don't ask me why that should always be null, because the view in
Oracle and DB2 should have same columns and Oracle view has col as
null)
So i try ...
Create view......null as col.......

It fails in DB2, but works in Oracle.

Please tell what should be done to set the field as null.

Thanks a lot

Rahul
Aug 16 '07 #1
  • viewed: 1134
Share:
2 Replies
Jal
Rahul,

Create your table or view with the defualt clause on the Column which you want to have null value.

Create table test (
Col1 Char,
Col2 Int,
MyNullCol Char DEFAULT NULL
)


Jalaj
Aug 17 '07 #2
Well You Can Select Null same as in Oracle (i.e select Null as Val1 from dual). Try the following SQL in DB2 (v 9.5)

Select cast(NULL as CHAR) as v1 From sysibm.sysdummy1

and to make sure that it is returning Null i check the results using nvl

e.g.
Select nvl(cast(NULL as CHAR),'ok thi is null') as v1 From sysibm.sysdummy1

I tried these Command in Toad for DB2
Oct 26 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Raquel | last post: by
5 posts views Thread by Mike Gemmell | last post: by
3 posts views Thread by bughunter@ru | last post: by
1 post views Thread by alex.mcshane@btinternet.com | last post: by
2 posts views Thread by gimme_this_gimme_that@yahoo.com | last post: by
5 posts views Thread by Rahul B | last post: by
1 post views Thread by kropinek@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.