Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Oracle stored procedure rewrite
Oracle stored procedure rewrite
Create or replace the procedure pro_unit_cacl(v_string varchar2, cur_arg out sys_refcursor).

be like

Num number;

Num 1 number;

C2 varchar 2(50);

Cur2 cursor is

Select to _ char (a.wyid) from v _ unit _ classiftya where a. FILE _ ID = v _ string.

begin

Open cur2

ring

Take cur2 into C2;

Select D. sum into num1from v _ unit _ classsifty d where d. WYID = c2.

num:= 1;

While num & lt=num 1 cycle

begin

insert into unit _ house select d . FILE _ ID,d.FILE_TYPE,d.TYPE,0,0,d . FILE _ TYPE | | ' _ ' | | lpad(round(DBMS _ random . value( 1,5)), 1,0)| ' _ ' | | d . TYPE | | ' _ ' | | lpad(round(DBMS _ random . value( 1,5)), 1,0)from v _ unit _ unit& gtJBWH’;

num:= num+ 1;

Submit;

End;

End the cycle;

Exit when cur2%Notfound;

End the cycle;

Turn off cur2

Opencur _ arg for select * from unit _ house-saves the result data in the cursor and returns it.

End;