Search code examples
plsqlprocedure

How to insert multiple values in table using procedure in PL/SQL?


On running the following code I'm getting this as output:

OUTPUT:- ORA-00001: unique constraint (KART.SYS_C007206) violated

I think I'm inserting batch of values at a time in database. Maybe that's why it's not working.

      <!--  declare
      Enter_the_size_of_array int;
      id int;
      name varchar(30);
      age int
      c int;


      procedure s(a in out int , b in out varchar2,c in out int) is 
                begin 
                insert into table1 values(a,b,c);
                end;

      begin
      c:=1;
      Enter_the_size_of_array:= :Enter_the_size_of_array;


      loop 
                id:= :id;
                name:= :name;
                age:= :age;
                s(id,name,age);
                c:=c+1;
      exit when (c=Enter_the_size_of_array);
      end loop;

      end;
      / -->

Solution

  • Assuming ID is a unique key field. every time you have enter the same value for ID. it throws unique key constraint exception.