Gs Prep
Gs Prep

Reputation: 11

What is wrong in this code i tried in oracle

CREATE TABLE sales ( "customer_id" VARCHAR(1) ,"order_date" DATE ,"product_id" INTEGER );

INSERT INTO sales ( customer_id ,order_date ,product_id ) VALUES ( 'A' ,'2021-01-01' ,1 );
( 'A' ,'2021-01-01' ,2 );
( 'A' ,'2021-01-07' ,2 );
( 'A' ,'2021-01-10' ,3 );
( 'A' ,'2021-01-11' ,3 );
( 'A' ,'2021-01-11' ,3 );
( 'B' ,'2021-01-01' ,2 );
( 'B' ,'2021-01-02' ,2 );
( 'B' ,'2021-01-04' ,1 );
( 'B' ,'2021-01-11' ,1 );
( 'B' ,'2021-01-16' ,3 );
( 'B' ,'2021-02-01' ,3 );
( 'C' ,'2021-01-01' ,3 );
( 'C' ,'2021-01-01' ,3 );
( 'C' ,'2021-01-07' ,3 );

Upvotes: 0

Views: 32

Answers (1)

Sachin Padha
Sachin Padha

Reputation: 221

Since

  • you are using double codes in the column name and Oracle expecting case sensitive name
  • only the first statement conforms the INSERT statement syntax, while the rest should be fixed

So, the correct statements for all of those current lines would like to be the following:

INSERT INTO Sales
  ("customer_id",
   "order_date",
   "product_id")
VALUES
  ('A',
   date'2021-01-01', -- date literal is fixed
   1);

Upvotes: 3

Related Questions