views:

69

answers:

2

I haven't used Oracle for a while so I'm a bit rusty.

This is my table:

create table calendar(
username VARCHAR2(12),
content VARCHAR2(100),
dateContent DATE,
type CHAR(3) CHECK (type IN ('PUB', 'PRV')));

But when I try to insert a value like this:

insert into calendar
(username, content, dateContent, type) 
values
(chris, assignment due, to_date('01-OCT-2010 13:00','DD-MON-YYYY HH24:MI'), PUB)
/

I am getting:

ORA-00984: column not allowed here

pointing to the type column at the end. I have a feeling I'm not getting something right with the DATE field as I've never really used it.

What have I done wrong?

+2  A: 

Could it be because type is a Oracle reserved word ?

Looks like this is not an issue. Read the comment by APC.

I'm not deleting this answer because I find the comment useful.

codaddict
TYPE is a reserved but not the sort of reserved word which can't be used. This is because TYPE only became a reserved word in Oracle8 (the so-called ORDBMS release). By then there was a huge codebase in existence which had legitimately used TYPE as a column name. For instance the data dictionary's USER_SOURCE view. So banning the use of TYPE as a column name would break a lot of applications.
APC
+6  A: 

You need to put quotes round the varchar2 values

Something like

insert into calendar(username, 
                     content, 
                     dateContent, 
                     type) 
  values('chris', 
         'assignment due', 
         to_date('01-OCT-2010 13:00','DD-MON-YYYY HH24:MI'), 
         'PUB');
Richard
That seemed to do the trick. Thanks
Jackass
It is a misleading error message and the sort of thing which catches us all out, rusty or not.
APC