2

I am trying to run the following command in Oracle 11g but keep getting an error of 'commmand not properly ended'. I am new to Oracle and I haven't been able to find anything about insert multiple value sets (unless they are selected from a table which in this case they are not)....

INSERT INTO category (catcode, catdesc)
VALUES ('BUS', 'BUSINESS'),
    ('CHN', 'CHILDREN'),
    ('COK', 'COOKING'),
    ('COM', 'COMPUTER'),
    ('FAL', 'FAMILY LIFE'),
    ('FIT', 'FITNESS'),
    ('SEH', 'SELF HELP'),
    ('LIT', 'LITERATURE'),
    ('CHN', 'CHILDREN'),
    ('BUS', 'BUSINESS');

If this syntax is completely off, then how can I insert multiple values in one statement?

2 Answers 2

9

Try like this,

INSERT ALL 
     INTO category (catcode, catdesc) VALUES ('BUS', 'BUSINESS')
     INTO category (catcode, catdesc) VALUES ('CHN', 'CHILDREN')
     INTO category (catcode, catdesc) VALUES ('COK', 'COOKING')
     INTO category (catcode, catdesc) VALUES ('COM', 'COMPUTER')
     INTO category (catcode, catdesc) VALUES ('FAL', 'FAMILY LIFE')
     INTO category (catcode, catdesc) VALUES ('FIT', 'FITNESS')
     INTO category (catcode, catdesc) VALUES ('SEH', 'SELF HELP')
     INTO category (catcode, catdesc) VALUES ('LIT', 'LITERATURE')
     INTO category (catcode, catdesc) VALUES ('CHN', 'CHILDREN')
     INTO category (catcode, catdesc) VALUES ('BUS', 'BUSINESS')
SELECT * FROM DUAL;

Refer here for more in detail.

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

Comments

5

You can always use insert . . . select syntax:

INSERT INTO category (catcode, catdesc)
    select 'BUS', 'BUSINESS' from dual union all
    select 'CHN', 'CHILDREN' from dual union all
    select 'COK', 'COOKING' from dual union all
    select 'COM', 'COMPUTER' from dual union all
    select 'FAL', 'FAMILY LIFE' from dual union all
    select 'FIT', 'FITNESS' from dual union all
    select 'SEH', 'SELF HELP' from dual union all
    select 'LIT', 'LITERATURE' from dual union all
    select 'CHN', 'CHILDREN' from dual union all
    select 'BUS', 'BUSINESS' from dual;

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.