1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| SQL> create table t(c1 number primary key, c2 varchar2(10))
2 /
Table created.
SQL> create or replace procedure p (p_c1 number,p_c2 varchar2) as
2 begin
3 insert into t (c1, c2) values (p_c1, p_c2);
4 end;
5 /
Procedure created.
SQL> begin
2 for c in (select 1 as c1, 'toto' as c2 from dual union all
3 select 2 as c1, 'titi' as c2 from dual) loop
4 p(c.c1, c.c2);
5 end loop;
6 commit;
7 end;
8 /
PL/SQL procedure successfully completed.
SQL> select * from t
2 /
C1 C2
---------- ----------
1 toto
2 titi
SQL> begin
2 for c in (select 3 as c1, 'toto3' as c2 from dual union all
3 select 4 as c1, 'titi4' as c2 from dual union all
4 select 5 as c1, 'toto5' as c2 from dual union all
5 select 3 as c1, 'titi3' as c2 from dual) loop
6 p(c.c1, c.c2);
7 end loop;
8 commit;
9 end;
10 /
begin
*
ERROR at line 1:
ORA-00001: unique constraint (OREL.SYS_C007844) violated
ORA-06512: at "OREL.P", line 3
ORA-06512: at line 6
SQL> select * from t
2 /
C1 C2
---------- ----------
1 toto
2 titi
SQL> |
Partager