-
Notifications
You must be signed in to change notification settings - Fork 0
1.1 Pl SQL STORE PROCEDURE
thuantt0101 edited this page Nov 30, 2019
·
2 revisions
#1. Normal Store Procedure
create or replace PROCEDURE PROCEDURE1
AS
v_yes BOOLEAN;
BEGIN
/*for loop in oracle*/
FOR v_x in 1..10
LOOP
DBMS_OUTPUT.PUT_LINE(v_x);
END LOOP;
v_yes := true;
/*if else statement*/
if v_yes = true Then
DBMS_OUTPUT.PUT_LINE('v_yes: ' || 'true');
Else
DBMS_OUTPUT.PUT_LINE('v_yes is ' || 'false');
end if;
END PROCEDURE1;
CREATE OR REPLACE PROCEDURE PROCEDURE_TABLE AS
CURSOR c_TBL1 is
SELECT ID,TBL1_NAME FROM TBL1;
TYPE c_list IS TABLE of tbl1.tbl1_name%type INDEX BY binary_integer;
name_list c_list;
TYPE c_id_list IS TABLE of tbl1.ID%type INDEX BY binary_integer;
id_list c_id_list;
v_counter integer :=0;
BEGIN
FOR n IN c_TBL1
LOOP
v_counter := v_counter + 1;
name_list(v_counter) := n.TBL1_NAME;
id_list(v_counter) := n.ID;
DBMS_OUTPUT.PUT_LINE(name_list(v_counter));
DBMS_OUTPUT.PUT_LINE(id_list(v_counter));
END LOOP;
END PROCEDURE_TABLE;