-- this is GOOFY to do on the database tier, but it is a quick-n- -- sleazy classic procedure involving input-output parameters d -- (parameters used as BOTH input and output) -- -- by: Sharon Tuttle -- last modified: 3-13-13 ---------- -- signature: procedure swap: INOUT number INOUT number -> void -- purpose: expects two arguments whose values CAN be changed, -- and returns nothing, but does have the side-effect that -- afterwards the first argument has the value of the -- second argument, and vice versa create or replace procedure swap(value1 IN OUT number, value2 IN OUT number) as temp number; begin temp := value1; value1 := value2; value2 := temp; end; / show errors set serveroutput on prompt ========================================= prompt TESTING swap -- setting two var num1 number var num2 number exec :num1 := 13 exec :num2 := 48 prompt ============== prompt before swap call: print num1 print num2 exec swap(:num1, :num2) prompt ============== prompt AFTER swap call: prompt num1 WAS 13; it is NOW: print num1 prompt num2 WAS 48; it is NOW: print num2