我有两个模式SCHEMA_1和SCHEMA_2。
在SCHEMA_1中,我有2个表,LOCATIONS和COUNCILS,具有下一个结构:
CREATE TABLE SCHEMA_1.COUNCILS
( ID NUMBER(*,0),
DCOUNCIL VARCHAR2(200 BYTE),
CONSTRAINT COUNCILS_PK PRIMARY KEY ("ID")
);
CREATE TABLE SCHEMA_1.LOCATIONS
( ID NUMBER(*,0),
DLOCATION VARCHAR2(200 BYTE),
COUNCIL_ID NUMBER(*,0),
CONSTRAINT LOCATIONS_PK PRIMARY KEY ("ID"),
CONSTRAINT LOCATIONS_R01 FOREIGN KEY ("COUNCIL_ID")
REFERENCES SCHEMA_1.COUNCILS ("ID") ENABLE
);
我还在SCHEMA_1中编译了一个包,其中包含一个函数 选择理事会内所有地点的面额:
CREATE OR REPLACE PACKAGE SCHEMA_1.PAQ_LOCATIONS
IS
TYPE t_TABLE_LOCATIONS IS TABLE OF LOCATIONS%ROWTYPE
INDEX BY BINARY_INTEGER;
FUNCTION OBTAIN_ALL
(
pe_council_id IN COUNCILS.ID%TYPE
)
RETURN t_TABLE_LOCATIONS;
END PAQ_LOCATIONS;
CREATE OR REPLACE PACKAGE BODY SCHEMA_1.PAQ_LOCATIONS
IS
FUNCTION OBTAIN_ALL
(
pe_council_id IN COUNCILS.ID%TYPE
)
RETURN t_TABLE_LOCATIONS
IS
CURSOR cur_locations
IS
SELECT *
FROM LOCATIONS
WHERE COUNCIL_ID = pe_council_id;
v_tlocations t_TABLE_LOCATIONS;
v_counter BINARY_INTEGER;
BEGIN
v_counter := 0;
FOR reg_location IN cur_locations
LOOP
v_contador := v_counter + 1;
v_tlocations ( v_counter ) := reg_location;
END LOOP;
RETURN v_tlocations;
END OBTAIN_ALL;
END PAQ_LOCATIONS;
然后,我已将“PAQ_LOCATIONS”的执行权限授予“SCHEMA_2”。
PRIVILEGE GRANTEE GRANTABLE GRANTOR OBJECT_NAME
EXECUTE SCHEMA_2 NO SCHEMA_1 PAQ_LOCATIONS
在“ESQUEMA_2”中,我尝试执行“PAQ_LOCATIONS”:
DECLARE
v_locations SCHEMA_1.PAQ_LOCATIONS.t_TABLE_LOCATIONS;
BEGIN
v_locations := SCHEMA_1.PAQ_LOCATIONS.OBTAIN_ALL ( 6015 );
FOR i IN v_locations.FIRST .. v_locations.LAST
LOOP
DBMS_OUTPUT.put_line ( v_locations (i).DLOCATION );
END LOOP;
END;
然后抛出异常:
"
Error que empieza en la línea: 1 del comando :
DECLARE
...etc...
END;
ORA-06550: línea 2, columna 27:
PLS-00201: identifier 'SCHEMA_1.PAQ_LOCATIONS' must be declared
ORA-06550: línea 2, columna 27:
PL/SQL: Item ignored
ORA-06550: línea 5, columna 8:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: línea 5, columna 8:
PL/SQL: Statement ignored
ORA-06550: línea 7, columna 22:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: línea 7, columna 8:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
"