Khalil Ismail
Khalil Ismail

Reputation: 38

oracle express 11g exception weird

CREATE TABLE  "EMPLOYEE" 
("SSN" NUMBER(*,0) NOT NULL ENABLE, 
 "MANAGER_SSN" NUMBER(*,0) NOT NULL ENABLE, 
 "STREET" CHAR(40) NOT NULL ENABLE, 
 "CITY" CHAR(25) NOT NULL ENABLE, 
 "DEP_NO" NUMBER(*,0) NOT NULL ENABLE, 
 "NAME" CHAR(15) NOT NULL ENABLE, 
 "SALARY" NUMBER(8,2) NOT NULL ENABLE, 
 "HIRE_DATE" DATE, 
 CONSTRAINT "PK_EMPLOYEE" PRIMARY KEY ("SSN") ENABLE
)

and when i try to insert into that table :

insert into employee values (1,1,"cola","beirut",1,"mohamad",1500,"7-feb-1999")

it says : ORA-00984: column not allowed here what the hell is this !!!!! why this error is happening " it is not a matter of small or capital letter "

Upvotes: 0

Views: 88

Answers (2)

Joachim Isaksson
Joachim Isaksson

Reputation: 180897

There seem to be two separate problems;

  • You need to quote literal strings with ' in Oracle, double quotes are used for quoting object names for case sensitivity.
  • Your database does not seem to use the 7-Feb-1999 date format by default, so you'll have to tell it which format you're using.

All in all, the query should be;

INSERT INTO employee 
  VALUES (1, 1, 'cola', 'beirut', 1, 'mohamad', 1500, 
          TO_DATE('7-feb-1999', 'DD-MON-YYYY'));

An SQLfiddle to test with.

Upvotes: 1

Mureinik
Mureinik

Reputation: 311163

In Oracle, varchar literals are marked by single quote ('), not double quotes ("). Double quotes denote case-sensitive object names, such as columns.

Just switch your double quotes to single quotes and you'll be fine:

insert into employee values (1,1,'cola','beirut',1,'mohamad',1500,'7-feb-1999')

Upvotes: 1

Related Questions