Skip to Main Content
  • Questions
  • ORA-00984: column not allowed here in 11g but not in 12c ?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Hariharan.

Asked: September 11, 2016 - 4:52 am UTC

Last updated: November 05, 2019 - 3:59 am UTC

Version: 11.2.0.4

Viewed 10K+ times! This question is

You Asked

Hi Team,

Please check below case are we missing something in 12c ? or incorrect in syntactical wise ?


SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

SQL> create sequence s;

Sequence created.

SQL> create table t ( x int default s.nextval primary key, y varchar2(30) );
create table t ( x int default s.nextval primary key, y varchar2(30) )
*
ERROR at line 1:
ORA-00984: column not allowed here


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE 12.1.0.2.0 Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production

SQL> create sequence s;

Sequence created.

SQL> create table t ( x int default s.nextval primary key, y varchar2(30) );

Table created.

SQL>


++ Why issue in 11g
++ How 12c Reading it properly
++ What needs to be done to correct the issue in 11g



Thanks,


and Connor said...

The ability to use a sequence in a DEFAULT clause is new in 12c.

You can't do it in 11g.

Workarounds:
- use a trigger to populate the column with the sequence value
- wrap the insert within a PLSQL program so you can control the insert semantics and explicitly code the seq.nextval.


Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Helpfull

Hariharan Senthil pandiyan, September 12, 2016 - 3:21 am UTC

Thanks for the hints. Also i found links related to your update.

http://www.oracle.com/technetwork/issue-archive/2013/13-sep/o53asktom-1999186.html

Thank you very much!!
Connor McDonald
September 12, 2016 - 12:15 pm UTC

Happy to help.

Perfect answer

Michael Murphy, November 03, 2019 - 3:16 pm UTC

Would never have figures it out without your help. Thanks, it was wrecking my head.
Connor McDonald
November 05, 2019 - 3:59 am UTC

Glad we could help

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library