473,698 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select null as xyz from sysibm.sysdummy 1

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 7380
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
4023
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 values (4);
5
5684
by: Mike Gemmell | last post by:
create table ppp ( t int ) @ create view v_ppp as select t from ppp @
3
14932
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
2253
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 accessed via SQL within the SP? Both an Explain against the Plan_Table and SYSPACKDEP state that the Table is used. >From the Plan_Table:- - Lock Mode: UR Isolation
19
2282
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 the server. It would be nice if I can get the server CPU utilization (and other key factors) from db2 via jdbc. However, it needs to be low cost, since it would likely run every x seconds. System: db2 v 9.1 64bit on Centos 4.3 64 bit. Thank...
5
18108
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
2025
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 z.r_name,b.r_id from (select r_name from z.r_lookup where r_id=821 ) z
2
1335
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 and DB2 should have same columns and Oracle view has col as null) So i try ... Create view......null as col.......
1
5167
by: kropinek | last post by:
Hello! I have got: SELECT char(week_iso(current date)) FROM sysibm.sysdummy1 +------------+ | 00001 | +------------+ | 45 | +------------+
0
8678
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
8609
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
9166
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
8899
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
7737
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...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
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
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.