Calling the required procedure from a package using an input parameter

tell me how to organize the call of the required procedure from the package by the input parameter. An example of my code, where the meaning is clear, I will attach. I really need help in the implementation of this assignment. At the input, we receive a line and, depending on the text of this line, we use the necessary procedure inside the package, deleting, clearing or copying the table. Thanks in advance for your help!

    create  table test1
(
    test1   varchar2(10),
    valtest number(5)
);
insert into test1 values('hello',0110);
insert into test1 values('bye',1010);



CREATE OR REPLACE PACKAGE pck as
TYPE refc IS REF CURSOR;
PROCEDURE p1
(   intake          varchar2, 
    rc    IN OUT refc
);
PROCEDURE p2 (
    intake          varchar2, 
    rc    IN  OUT refc
    
);
PROCEDURE p3 (
  intake          varchar2, 
    rc    IN  OUT refc
);
 
end;
create or replace package body pck as
PROCEDURE pr1 (
    intake          varchar2(10),
    rc    IN OUT mrc
)
IS
BEGIN
    OPEN rc FOR SELECT * FROM test1;
    IF rc IN ('delt')
    THEN DROP TABLE test1;
    dbms_output.put_line ('table droped!');
    END IF;
END;


PROCEDURE pr2 (
    intake          varchar2(10),
    rc    IN  OUT mrc
)
BEGIN
   OPEN rc FOR SELECT * FROM test1;
   IF rc IN ('trunct')
    THEN TRUNCATE TABLE test1;
    dbms_output.put_line ('table truncated!');
    END IF;
END;


PROCEDURE pr3 (
    intake          varchar2(10),
    rc    IN  OUT mrc
)
IS
BEGIN
  OPEN rc FOR SELECT * FROM test1;
   IF rc IN ('copy')
    THEN CREATE TABLE test2 AS SELECT * FROM test1;
    dbms_output.put_line ('table copyed!');
    END IF;
END;


end; 

Leave a Reply

Your email address will not be published.