Question

  Asked: Jan 5 2008   11:57 AM GMT
  Asked by: Tgee


Assign default values to SQL VIEW columns


SQL, Oracle Views, DB2/400

I'm trying to assign default values to VIEW columns defined for left joined columns or columns created by aggregate functions. I've tried the ALTER TABLE after the VIEW was created but get an error that my VIEW is not a TABLE and the ALTER VIEW is not supported by DB2/400 v5r3.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
-1
Click to Vote:
  •   0
  •  -1



Try using "CREATE OR REPLACE VIEW..."
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development, Oracle and AS/400.

Looking for relevant Development Whitepapers? Visit the SearchWinDevelopment.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Tgee  |   Jan 9 2008  10:57PM GMT

I used “CREATE VIEW”. See example below:

When this VIEW is used in other queries with LEFT OUTER JOIN, I want GDSCQY and GDPQTY to default to 0 instead of NULL. I also want SHPWTYP to default to blank instead of NULL.

———————————————————————-
create view PDGRDDV12 as
select
GDLVL1, GDLVL2, WHFLOC, WHWTYP as SHPWTYP, GDITEM,
GDSTYL, GDCOLR, GDLOGO, GDSIZ#,
cast(sum(GDSCQY) as dec(7,0)) as GDSCQY,
cast(sum(GDPQTY) as dec(7,0)) as GDPQTY

from PDGRDDP
left outer join ICWAREP on GDWHSI=WHWHSI

where GDSTTS=’5′ or GDSTTS=’6′

group by GDLVL1, GDLVL2, WHFLOC, WHWTYP, GDITEM,
GDSTYL, GDCOLR, GDLOGO, GDSIZ#;
————————————————————————