By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,226 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,226 IT Pros & Developers. It's quick & easy.

Select null as xyz from sysibm.sysdummy1

P: 11
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
Share this Question
Share on Google+
2 Replies


P: 10
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

P: 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.