Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Virtual column NOT NULL

Peter GjelstrupMay 30 2011 — edited May 30 2011
Hello fellow members,

Can anyone reproduce this?
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Create a small table:
SQL> create table t(x number not null);

Table created.
Now add a virtual column, using decode:
SQL> alter table t add (y varchar2(1) as (decode(x, 1, 'A', 'B')) not null);

Table altered.
"Same" column, using case
SQL> alter table t add (z varchar2(1) as (case x when 1 then 'A' else 'B' end));

Table altered.
Only it was not the same, I wanted to make it NOT NULL.
If I do so, I get:
SQL> alter table t add (w varchar2(1) as (case x when 2 then 'A' else 'B' end) not null);
alter table t add (w varchar2(1) as (case x when 2 then 'A' else 'B' end) not null)
                                                                 *
ERROR at line 1:
ORA-03113: EOF pÕ kommunikationskanal
Process ID: 3400
Session ID: 140 Serial number: 213
This is consistent at this database on my laptop.


Regards
Peter
This post has been answered by MichaelS on May 30 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2011
Added on May 30 2011
5 comments
1,228 views