when I enter this
INSERT INTO works_on
(essn, pno, hours)
values
(\'123456789\', 1, 32.5),
(\'123456789\', 2, 7.5),
(\'666884444\', 3, 40.0),
(\'453453453\',
try take a look at this by ShoeLace
Oracle SQL uses a semi-colon ; as its end of statement marker. you will need to add the ; after bother insert statments. NB: that also assumes ADODB will allow 2 inserts in a single call. the alternative might be to wrap both calls in a block, BEGIN insert (...) into (...); insert (...) into (...); END;
The VALUES
syntax supports inserting only one entries into a database. In the ORACLE FAQs, the following is suggested:
INSERT ALL
INTO works_on (essn, pno, hours) VALUES ('123456789', 1, 32.5)
INTO works_on (essn, pno, hours) VALUES ('123456789', 2, 7.5)
INTO works_on (essn, pno, hours) VALUES ('666884444', 3, 40.0)
INTO works_on (essn, pno, hours) VALUES ('453453453', 1, 20.0)
INTO works_on (essn, pno, hours) VALUES ('453453453', 2, 20.0)
INTO works_on (essn, pno, hours) VALUES ('333445555', 2, 10.0)
INTO works_on (essn, pno, hours) VALUES ('333445555', 3, 10.0)
INTO works_on (essn, pno, hours) VALUES ('333445555', 10, 10.0)
INTO works_on (essn, pno, hours) VALUES ('333445555', 20, 10.0)
INTO works_on (essn, pno, hours) VALUES ('999887777', 30, 30.0)
INTO works_on (essn, pno, hours) VALUES ('999887777', 10, 10.0)
INTO works_on (essn, pno, hours) VALUES ('987987987', 10, 35.0)
INTO works_on (essn, pno, hours) VALUES ('987987987', 30, 5.0)
INTO works_on (essn, pno, hours) VALUES ('987654321', 30, 20.0)
INTO works_on (essn, pno, hours) VALUES ('987654321', 20, 15.0)
INTO works_on (essn, pno, hours) VALUES ('888665555', 20, 0)
SELECT * FROM dual;
You cannot combine all your values in a single insert like that in Oracle unfortunately. You can either separate your SQL statements, or use another approach like this to run in a single statement:
INSERT INTO works_on (essn, pno, hours)
SELECT '123456789', 1, 32.5 FROM DUAL UNION
SELECT '123456789', 2, 7.5 FROM DUAL UNION
SELECT '666884444', 3, 40.0 FROM DUAL UNION
SELECT '453453453', 1, 20.0 FROM DUAL UNION
...
SELECT '987987987', 30, 5.0 FROM DUAL UNION
SELECT '987654321', 30, 20.0 FROM DUAL UNION
SELECT '987654321', 20, 15.0 FROM DUAL UNION
SELECT '888665555', 20, 0 FROM DUAL
SQL Fiddle Demo
INSERT INTO
WORKS_ON VALUES
(&ESSN,&PNO,&HOURS);
After u'll get like below dat.
ENTER VALUE FOR ESSN: IN THIS U ENTER 123456789
ENTER VALUE FOR PNO: IN THIS U ENTER 1
ENTER VALUE FOR HOURS:32.5
After that You'll get:
1 ROW IS CREATED
Then type '/'
symbol and press enter. You'll get for enter for insert another row into that table.
Follow above procedure for easy way to insert row into tables.
In Oracle, you can't specify multiple sets of values like this (I'm guessing that you're coming from a MySQL background where that syntax is allowed). The simplest approach is to generate multiple INSERT
statements
INSERT INTO works_on
(essn, pno, hours)
values
('123456789', 1, 32.5);
INSERT INTO works_on
(essn, pno, hours)
values
('123456789', 2, 7.5);
INSERT INTO works_on
(essn, pno, hours)
values
('666884444', 3, 40.0);
...
You can also insert multiple rows using a single INSERT ALL
statement
INSERT ALL
INTO works_on(essn, pno, hours) values('123456789', 1, 32.5)
INTO works_on(essn, pno, hours) values('123456789', 2, 7.5)
INTO works_on(essn, pno, hours) values('666884444', 3, 40.0)
INTO works_on(essn, pno, hours) values('453453453', 1, 20.0)
INTO works_on(essn, pno, hours) values('453453453', 2, 20.0)
INTO works_on(essn, pno, hours) values('333445555', 2, 10.0)
INTO works_on(essn, pno, hours) values('333445555', 3, 10.0)
...
SELECT *
FROM dual;