0
create table orders(
    ord_id numeric(5) primary key,
    purch_Atm float(8),
    ord_date date,
    Customer_id Numeric(5),
    foreign key (customer_id) references customer1 (customer_id),
    Salesman_id Numeric(5),
    foreign key (Salesman_id) references salesman(Salesman_id))

insert into orders values (70001,150.5,'2012-10-05',3005,5002);
insert into orders values (70009,270.65,'2012-09-10',3001,5005);
insert into orders values (70002,65.26,'2012-10-05',3002,5001);
insert into orders values (70004,110.5,'2012-08-17',3009,5003);
insert into orders values (70007,948.5,'2012-09-10',3005,5002);
insert into orders values (70005,2400.6,'2012-07-27',3007,5001);
insert into orders values (70008,5760,'2012-09-10',3002,5001);
insert into orders values (70010,1983.2,'2012-10-10',3004,5006);
insert into orders values (70003,2480.4,'2012-10-10',3009,5003);
insert into orders values (70012,250.45,'2012-06-27',3008,5002);
insert into orders values (70011,75.29,'2012-08-17',3003,5007);
insert into orders values (70013,3045.6,'2012-04-25',3002,5001);

Table is inserted correctly as far as I can tell. I used the same insert format for my other tables but it will not work for this one. I am not sure why so please help.

This is what it gives me for errors: Error report - SQL Error: ORA-01861: literal does not match format string 01861. 00000 - "literal does not match format string" *Cause: Literals in the input must be the same length as literals in the format string (with the exception of leading whitespace). If the "FX" modifier has been toggled on, the literal must match exactly, with no extra whitespace. *Action: Correct the format string to match the literal.

1
  • 3
    Use explicit date conversion: to_date('2012-10-05'', 'yyyy-mm-dd'). Or set a default date format of your session: ALTER SESSION SET NLS_DATE_FORMAT='yyyy-dd-mm' Commented May 9, 2016 at 15:13

2 Answers 2

2

For your case, I think you should try this:

insert into orders values (70001,150.5,to_date('2012-10-05','yyyy-MM-dd'),3005,5002);

Or

insert into orders values (70001,150.5,'05-OCT-12',3005,5002);

Or you can keep your format and work with NLS_DATE_FORMAT

Sign up to request clarification or add additional context in comments.

Comments

1

You must set your NLS_DATE_FORMAT to yyyy-mm-dd

ALTER SESSION SET NLS_DATE_FORMAT='yyyy-mm-dd' 

Otherwise date is not recognized as one.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.