Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2012

    Unanswered: INSERT INTO SELECT issue

    I have a scenario where in i should achieve the below.

    if (bonusflag=FALSE)
    insert into emp_sal select emp_no , no_of_hours*60 as emp_sal from emp
    where no_of_hours = 4

    insert into emp_sal select emp_no , (no_of_hours*60) + 5000 as emp_sal from emp where emp_no >100 and no_of_hours > 6

    Now, while doing the same thru pl/sql can you help me how to write the code as we can not use execute immediate because the above queries will return more than 1 row.


  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    below is valid SQL that will not throw error due to multiple rows from SELECT
    INSERT INTO emp_sal 
    SELECT emp_no, 
           no_of_hours * 60 AS emp_sal 
    FROM   emp 
    WHERE  no_of_hours = 4
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts