CREATE OR REPLACE PROCEDURE drop_object ( ObjName IN VARCHAR2 ) IS counter NUMBER := 0; to_drp VARCHAR2(200) := UPPER(ObjName); drp_stmt VARCHAR2(200) := NULL; BEGIN SELECT COUNT(*) INTO counter FROM user_tables WHERE table_name = to_drp; IF counter = 1 THEN drp_stmt := 'Drop Table ' || to_drp; EXECUTE IMMEDIATE drp_stmt; END IF; SELECT COUNT(*) INTO counter FROM user_sequences WHERE sequence_name = to_drp; IF counter = 1 THEN drp_stmt := 'DROP SEQUENCE ' || to_drp; EXECUTE IMMEDIATE drp_stmt; END IF; END DROP_OBJECT; /
Der Aufruf der Prozedur könnte z.B. so erfolgen:
CALL drop_object('t_test'); CREATE TABLE t_test ( test_id NUMBER, uid_text VARCHAR2(80) )
Keine Kommentare:
Kommentar veröffentlichen