Thursday, 30 August 2012

Example of more Dynamic function using varray of Separation


More dynamic function of separation
create or replace function separate4(a varchar2)return x
is
z x;
begin
z:=x(0,0,0,0,0,0,0,0,0,0);
for i in 1..9 loop
select  instr(a,',',1,i) into z(i) from dual;
end loop;
return z;
end;

Calling Environment for  more dynamic function
declare
  -- Local variables here
  a varchar2(30) :='10,20,30,40,50,60,70,80,90,100';
  b varchar2(10);
  c varchar2(10);
  r x;
  s y;
 begin
  s:=y(0,0,0,0,0,0,0,0,0,0);
  r:=separate4(a);
  for i in 1..9 loop
  select substr(a,r(i)-2,2) into s(i) from dual;
  dbms_output.put_line(s(i));
  end loop;
end;

No comments:

Post a Comment