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
| SQL> create table g_wrkTable (type_champ varchar2(30), champ2 varchar2(30));
Table created.
SQL>
SQL> insert into g_wrkTable (type_champ, champ2) values ('CODEPOSTAL',lpad('x',15,'x'));
1 row created.
SQL> insert into g_wrkTable (type_champ, champ2) values ('CODEPOSTAL',lpad('x',5,'x'));
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> create or replace function validateData
2 return sys.odcivarchar2list
3 pipelined is
4 l_message varchar2(500);
5 begin
6 for c in (select type_champ, champ2 from g_wrkTable) loop
7 if (c.type_champ = 'CODEPOSTAL' and length(c.champ2) > 12) then
8 l_message := ' (type_champ = '||c.type_champ||' , champ2 = '||c.champ2||') Le champ : champ2 doit avoir une longueur max de 5 ';
9 pipe row(l_message);
10 end if;
11 end loop;
12 end;
13 /
Function created.
SQL> show err
No errors.
SQL> select * from table(validateData)
2 /
COLUMN_VALUE
------------------------------------------------------------------------------------------------------------------------
(type_champ = CODEPOSTAL , champ2 = xxxxxxxxxxxxxxx) Le champ : champ2 doit avoir une longueur max de 5
SQL> |
Partager