Sample Header Ad - 728x90

How to create a stored procedure from another stored procedure dynamically in OracleI have

0 votes
1 answer
67 views
I have a Stored Procedure that outputs the DDL of another Stored Procedure. I need to execute this DDL dynamically. Meaning, the second Stored Procedure should get created when the first Stored Procedure is executed. Here's the pseudocode for P_GEN: CREATE OR REPLACE PROCEDURE P_GEN AS c1 SYS_REFCURSOR; stmt varchar2(4000); BEGIN open c1 for SELECT TXT FROM ( SELECT 'CREATE OR REPLACE PROCEDURE P_DEL' .... TXT FROM TBL ) ; DBMS_SQL.RETURN_RESULT(c1); END; / P_DEL, when created, would have the following code: CREATE OR REPLACE PROCEDURE P_DEL AS BEGIN DEL('TEMP1'); DEL('TEMP2'); DEL('TEMP3'); END; / I need P_DEL to be created when P_GEN is executed. How to accomplish this?
Asked by Vincy Wales (1 rep)
Feb 18, 2024, 09:44 PM
Last activity: Feb 23, 2024, 01:57 PM