truncate table output / ------------------------------------------------------------------------------- -- Create a procedure ------------------------------------------------------------------------------- CREATE or REPLACE PROCEDURE multiply IS -- Create a named procedure multiplier integer := 5; -- the declaration section BEGIN FOR num IN 1..10 LOOP INSERT into output VALUES ( num * multiplier ); END LOOP; END; / CALL multiply( ) -- Call the above procedure / SELECT * from output / truncate table output / ------------------------------------------------------------------------------- -- Create a procedure -- Procedure determines the proper greeting based on the time of day ------------------------------------------------------------------------------- CREATE or REPLACE PROCEDURE greeting(p_fname varchar2, p_lname varchar2) IS v_date date := sysdate; v_hour char(2) := to_char(v_date,'HH24'); BEGIN IF v_hour < 12 THEN insert into output values('Good morning ' || p_fname ||' '|| p_lname); ELSIF v_hour >= 12 and v_hour < 18 THEN insert into output values('Good afternoon '|| p_fname ||' '|| p_lname); ELSE insert into output values('Good evening ' || p_fname ||' '|| p_lname); END IF; END; / CALL greeting('Sam', 'Sultan') -- call the procedure / SELECT * from output