473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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
5 7353
aj
Try something along the lines of:

CAST(NULL as CHAR)
CAST(NULL AS DATE)
CAST(NULL as INTEGER)

hth

aj

Rahul B wrote:
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 #2
On Thu, 16 Aug 2007 12:25:06 -0000, Rahul B <ra***********@gmail.com>
wrote:
>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
CAST the NULL. Or, being it has to match Oracle, and Oracle uses a
zero-length string for NULL, just use ''.

B.
Aug 16 '07 #3
Rahul B wrote:
It fails in DB2, but works in Oracle.
What's the type of such a NULL in Oracle?
If I do:
CREATE TABLE T(c1) AS (SELECT NULL FROM DUAL)

What is c1?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 16 '07 #4
On Aug 16, 7:04 pm, Serge Rielau <srie...@ca.ibm.comwrote:
Rahul B wrote:
It fails in DB2, but works in Oracle.

What's the type of such a NULL in Oracle?
If I do:
CREATE TABLE T(c1) AS (SELECT NULL FROM DUAL)

What is c1?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Hi,

It seems we cannot create a table in Oracle with null as a column but
only a view or a simple select statement like
select null as xyz from dual;

It gives the error saying zero length columns are not allowed.

Rahul

Aug 16 '07 #5
Rahul B wrote:
It gives the error saying zero length columns are not allowed.
Seems like they default to a CHAR(0)....

Anyway, to make a long story short DB2's unwillingness to type NULL more
aggressively is rooted in the strong typing.
NULls are allowed for:
1. Input to CAST (obviously)
2. Input to stored procs (because there is no overloading by type)
3. Right hand side of SET clause (since the column/variable type is known)
4. INSERT VALUES clause (again casting to the column)

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 16 '07 #6

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

Similar topics

4
by: pgp.coppens | last post by:
All, Seeing the behaviour below on DB2 v8 on zOS create table test(intcol integer); insert into test values (1); insert into test values (2); insert into test values (3); insert into test...
5
by: Mike Gemmell | last post by:
create table ppp ( t int ) @ create view v_ppp as select t from ppp @
3
by: bughunter | last post by:
IMHO, statements like this is mistake typically. May be more better made this construction - I said about empty WHERE - invalid? A lot of data will saved... :-) Andy
1
by: alex.mcshane | last post by:
Hi - a straight-forward question for which I would be grateful for an explanation. Why are ALL SQL/PL Stored Procedures associated with SYSIBM.SYSDUMMY1 even though the latter is NOT directly...
19
by: natG | last post by:
On a warehouse app, our Java clients constantly load/insert rows into the db. I would like to throttle these inserts (1.5 million rows per hr) from the Java app, based on current 'busy state' of...
5
by: whitsey | last post by:
Here is what I have: SELECT (SELECT COUNT(*) AS SEARCHES FROM SEARCHES INNER JOIN GROUPS ON SEARCHES.SITE_ID = GROUPS.SITE_ID WHERE
2
by: gimme_this_gimme_that | last post by:
The following statement doesn't work and I need a tip. Here is a draft: This selects data from the z table. And fetches the next value for r_id_seq and creates a table named b. select...
2
by: Rahul B | last post by:
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...
1
by: kropinek | last post by:
Hello! I have got: SELECT char(week_iso(current date)) FROM sysibm.sysdummy1 +------------+ | 00001 | +------------+ | 45 | +------------+
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.