1. Example of storing data without parameters: Success: 0; beginwhilev_count10loopv_count: v_count + 2; dbms_output.put_line (v_count: | v_count); endloop; endtestwhileloop; execute the following command:
1. Example of storing data without parameters: create or replace procedure testwhileloop IS v_count number: = 0; begin while v_count 10 loop v_count: = v_count + 2; dbms_output.put_line (v_count: | v_count); end loop; end testwhileloop; execute the following command:
I. No Parameter Storage
Use the following storage as an example:
create or replace procedure testwhileloop IS v_count number := 0;begin while v_count < 10 loop v_count := v_count + 2; dbms_output.put_line('v_count:' || v_count); end loop;end testwhileloop;
Run the following command:
SQL> set serveroutput on;SQL> exec testwhileloop; v_count:2v_count:4v_count:6v_count:8v_count:10 PL/SQL procedure successfully completed SQL> drop procedure testwhileloop; Procedure dropped SQL>
Where:
Exec testwhileloop; command is used to execute storage
Drop procedure testwhileloop; command used to delete Storage
Ii. Storage with Parameters
create or replace procedure testwhileloop(i_count number) ISv_count number:=i_count;begin while v_count < 10 loop v_count := v_count + 2; dbms_output.put_line('v_count:' || v_count); end loop;end testwhileloop;
Run the following command:
SQL> exec testwhileloop(1); v_count:3v_count:5v_count:7v_count:9v_count:11 PL/SQL procedure successfully completed SQL> drop procedure testwhileloop; Procedure dropped SQL>
Where:
Exec testwhileloop (1); command used to execute storage
Drop procedure testwhileloop; command used to delete Storage