473,322 Members | 1,778 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,322 software developers and data experts.

Null Column on a view

How can I define a null column value for a view?

I need to create a view using UNION ALL, but i need to set some columns
as null.
It's possible? how?
I think also it's necessary to "cast" the value...

for example. . i have..

CREATE VIEW XYS AS
SELECT
'1' AS ROWTYPE,
CUSTOMER,
STRINGVALUE,
DATEVALUE
FROM X

UNION ALL
SELECT
'2' AS ROWTYPE,
CUSTOMER,
'' AS STRINGVALUE,
DATE('1970-01-01') AS DATEVALUE
FROM Y

and so on...
but i want the STRINGVALUE and DATEVALUE from Y are null value!!

I'm using db2, but the best solution is to have a generic syntax
Thank You to all
Robert

Jun 22 '06 #1
2 4088
CREATE VIEW XYS AS
SELECT '1' AS ROWTYPE, CUSTOMER,
STRINGVALUE, DATEVALUE
FROM X
UNION ALL
SELECT '2' AS ROWTYPE, CUSTOMER,
CAST (NULL AS VARCHAR(50)) AS STRINGVALUE,
CAST(NULL AS DATE) AS DATEVALUE
FROM Y;

You should place actual data type of X.STRINGVALUE instead of
VARCHAR(50) above.
I use VARCHAR(50) as an example.

Sincerely,
Mark B.
How can I define a null column value for a view?

I need to create a view using UNION ALL, but i need to set some columns
as null.
It's possible? how?
I think also it's necessary to "cast" the value...

for example. . i have..

CREATE VIEW XYS AS
SELECT
'1' AS ROWTYPE,
CUSTOMER,
STRINGVALUE,
DATEVALUE
FROM X

UNION ALL
SELECT
'2' AS ROWTYPE,
CUSTOMER,
'' AS STRINGVALUE,
DATE('1970-01-01') AS DATEVALUE
FROM Y

and so on...
but i want the STRINGVALUE and DATEVALUE from Y are null value!!

I'm using db2, but the best solution is to have a generic syntax
Thank You to all
Robert


Jun 22 '06 #2
Thank You Very Much Mark!

You save me!!!

Roberto

Jun 23 '06 #3

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

Similar topics

5
by: Jagdip Singh Ajimal | last post by:
I am creating the following view CREATE OR REPLACE VIEW AllMedics AS SELECT * FROM Medic m, Employee e WHERE e.EmployeeID = m.MedicID AND e.DateFinished = NULL; But all I get is "no rows...
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
3
by: A.M. de Jong | last post by:
Reading a lot about Nulls right now I still can't find a Technical reason to use it or not. For what I've understand is this: In an Ingres database a Null column has a standard extra storage...
10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
5
by: Robert Stearns | last post by:
Either I missed something, or ALTER TABLE does not have this capability. Is there any way of doing it except DROPping all constraints which mention this table, EXPORTing the data, DROPping the...
7
by: Douglas Buchanan | last post by:
I cannot access certain column values of a list box using code. I have a list box 'lstPrv' populated by the query below. SELECT tblPrv.fkPrvID, lkpCat.CatNm, lkpSrv.SrvNm, lkpCat.pkCatID,...
3
by: jerry.ranch | last post by:
I'm building my own crosstab table. If a crosstab field has no data in the entire field (as a result of filtering), I don't want to show that field. Is there a way to do this in a qry or frm...
6
by: axelsino | last post by:
I know this has been asked before and yes, I have read the section in the documentation about it. But, my question is: If I have setup mysql with strict_trans_tables, will MySQL allow "null"...
0
by: diane | last post by:
Just trying to upsize using VFP 9 with SQL 2005 using VFP remote views. One in particular keeps coming up and saying Cannot insert the value NULL into column, when I really don't think I am...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.