1. 程式人生 > 其它 >oracle儲存過程記錄

oracle儲存過程記錄

 1 CREATE OR REPLACE PROCEDURE PROC_OPR_NAME
 2 (
 3         AA   IN VARCHAR DEFAULT NULL, 
 4         BB   IN VARCHAR DEFAULT NULL,
 5         CC   IN VARCHAR DEFAULT NULL, 
 6 ) AS
 7         V_VAL     VARCHAR2(40);
 8         V_SQL     VARCHAR2(1000);
 9         VV_VAL    VARCHAR2(40);
10         VV_SQL    VARCHAR2
(1000); 11 V_UUID VARCHAR2(40); 12 CURSOR VV_LIST is SELECT * from TABLE T where T.COLUMN = '' AND T.COLUMN = AA AND T.COLUMN IS NULL; --定義遊標(集合) 13 14 BEGIN 15 16 IF CC is NULL THEN 17 RETURN; 18 END IF; 19 20 V_SQL :='SELECT COLUMN_NAME FROM TABLE'||AA||' WHERE COLUMN_NAME =
'''||BB||''''; 21 if BB =15900 then 22 V_SQL :='select '' from dual'; 23 end if; 24 EXECUTE IMMEDIATE V_SQL into V_VAL; 25 26 VV_SQL := 'SELECT MAX(COLUMN_NAME) FROM TABLE WHERE COLUMN_NAME=:1 AND COLUMN_NAME=:2 AND COLUMN_NAME=:3 AND COLUMN_NAME=:4'; 27 EXECUTE IMMEDIATE VV_SQL
28 INTO VV_VAL 29 USING AA, 333, 666, 888; 30 31 if CC =123456 then 32 33 FOR VALUE IN VV_LIST LOOP 34 35 V_UUID := RAWTOHEX(sys_guid()); 36 37 INSERT INTO TABLE(COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN, COLUMN) VALUES (V_UUID, '111', '111', '111', AA, VALUE.COLUMN_NAME, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 38 end loop; 39 end if; 40 END;