Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Howto do undo a default clause?
"Noons" <wizofoz2k_at_yahoo.com.au.nospam> wrote in message
news:3f2a40b9$0$31922$afc38c87_at_news.optusnet.com.au...
> "Tanel Poder" <tanel@@peldik.com> wrote in message
news:3f2a37c2$1_1_at_news.estpak.ee...
> >
> > Quite interesting issue, though ;)
> >
>
>
> Darn! I was afraid someone would say that...
> The problem I have is that we run a script
> that reads all this stuff and creates a XML
> schema from the info in dictionary.
>
> If there is nothing in default value, nothing
> gets into XML. Then the Java generator that
> creates the code for the DAOs for the system
> objects does the right thing.
>
> If there is something in there, even if it is
> the string 'NULL', it creates a <DEFAULT_VALUE>
> </DEFAULT_VALUE> tag. This in turn causes the
> code generator to throw a wobblie fit when it
> shoves the 'NULL' string into a NUMBER field!
I don't think this should happen see below.
SQL> desc work_table;
Name Null? Type ----------------------------------------- -------- -------------------- ID NUMBER DATA_CONTENT VARCHAR2(50)
SQL> alter table work_table add noons number default 0;
Table altered.
SQL> desc work_table;
Name Null? Type ----------------------------------------- -------- -------------------- ID NUMBER DATA_CONTENT VARCHAR2(50) NOONS NUMBER
SQL> insert into work_table (id,data_content) values(1,'test');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from work_table;
ID DATA_CONTENT NOONS ---------- -------------------------------------------------- ---------- 1 test 0
SQL> alter table work_table modify noons default null;
Table altered.
SQL> conn / as sysdba
Connected.
SQL> select default$
2 from obj$,col$
3 where obj$.obj#=col$.obj#
4 and col$.name='NOONS';
DEFAULT$
SQL> select obj$.obj#,default$
2 from obj$,col$
3 where obj$.obj#=col$.obj#
4 and col$.name='NOONS';
OBJ#
28844
null
SQL> select default$ from col$ where obj#=28844;
DEFAULT$
null
SQL> conn batch/batch
Connected.
SQL> insert into work_table(id,data
2 .
SQL> insert into work_table(id,data_content) values(2,'more stuff');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from work_table;
ID DATA_CONTENT NOONS ---------- -------------------------------------------------- ---------- 1 test 0 2 more stuff
NB this all is very similar to the asktom link dave posted. I think that what I learn from this is that in fact the default value of a column isn't ever really a default value in the sense of a constant, it is should be really thought of as the return value of a function - even if that function always returns the same result (like 0).
cheers
-- Niall Litchfield Oracle DBA Audit Commission UKReceived on Fri Aug 01 2003 - 06:16:24 CDT
![]() |
![]() |