Oracle INSERT multiple rows

250 views Asked by At

My statement will insert two out of the four student IDs. The ones that are inserted are Id's that already exist with another section number. I cant figure out why the other two are not inserted.

INSERT INTO enrollment
    (student_id,section_id,enroll_date,created_by,created_date,modified_by,modified_date)
SELECT
    student_id,'48',SYSDATE,'KABEL',SYSDATE,'KABEL',SYSDATE
FROM enrollment
WHERE student_id IN ('375','137','266','382');
1

There are 1 answers

0
HaveNoDisplayName On

There is nothing much wrong in your query. You are typo or by mistake choose INSERT table and SELECT query from one table as this does not make any sense, to select from one table and insert into same table.

Your select and Insert statement using the same table enrollment.

These should be two different table.

INSERT INTO enrollment <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-------Here Problem
  (student_id,section_id,enroll_date,created_by,created_date,
      modified_by,modified_date)
SELECT
    student_id,'48',SYSDATE,'KABEL',SYSDATE,'KABEL',SYSDATE
FROM enrollment   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-------Here Problem
WHERE student_id IN ('375','137','266','382');