Calling an Oracle procedure within a package from a different schema?

15.9k views Asked by At

I've created the following package with 3 procedures:

CREATE OR REPLACE PACKAGE PQ_PaqueteIntegrantes
AS 
PROCEDURE INTEG_INSERCIONES(paIdIntegrante IN CreadorTablas.INTEGRANTES.ID_INTEGRANTE%TYPE 
                           ,paNombre IN CreadorTablas.INTEGRANTES.NOMBRE%TYPE
                           ,paApellidoPaterno IN CreadorTablas.INTEGRANTES.APELLIDO_PATERNO%TYPE);

PROCEDURE INTEG_MODIFICACIONES(paIdIntegrante IN OUT CreadorTablas.INTEGRANTES.ID_INTEGRANTE%TYPE 
                              ,paNombre IN OUT CreadorTablas.INTEGRANTES.NOMBRE%TYPE
                         ,paApellidoPaterno IN OUT CreadorTablas.INTEGRANTES.APELLIDO_PATERNO%TYPE);

PROCEDURE INTEG_ELIMINCACIONES( 
               paIdIntegrante    IN OE.EJEMPLO_TRANSAC_CLASE.CUSTOMER_ID%TYPE
                                ,paMjeDescError OUT VARCHAR2
                                ,paCodeError    OUT NUMBER);             
END PQ_PaqueteIntegrantes;

I created those procedures with a user called Admin_proyectos. The first procedures makes "Inserts", the second one "Updates", and the last one "Deletes", all of them working on a table called Integrantes, that table comes from another user called CreadorTablas. My intention is to create another user called Admin, who will have the responsibility to do those things, using the procedures from this package, of course. I've tried doing an PL/SQL block, but it didn't work, neither with an EXEC.

2

There are 2 answers

0
Yigitalp Ertem On BEST ANSWER
GRANT EXECUTE ON ADMIN_PROYECTOS.PQ_PaqueteIntegrantes TO Admin

Then, you can call the procedures in this package with Admin user as

BEGIN
ADMIN_PROYECTOS.PQ_PaqueteIntegrantes.INTEG_INSERCIONES(paIdIntegrante, paNombre, paNombre);
END;
0
loljeene On

You can use execute immediate statement:

 l_sql_stmt := 'alter table ' || p_table_name || ' drop partition ' || i.PARTITION_NAME || ';';
            dbms_output.put_line( l_sql_stmt );
            execute immediate l_sql_stmt;