PLS-00201: identifier 'TYPE' must be declared
I think you main problem is the definition of you types.
You have to check which type is used in which line.
What you should have:
user1 -> NO TYPES, a package which calls user2-stuff
user2 -> Type1, Pack1, Proc1
Example:
-- Create your type on schema user2CREATE OR REPLACE TYPE USER2.TestType AS OBJECT( NEWATTRIB1 VARCHAR2(1000))/-- Create your package at user2CREATE OR REPLACE PACKAGE user2.TestPackage AS FUNCTION MyFunction(Param1 IN TestType) RETURN TestType;END TestPackage;/CREATE OR REPLACE PACKAGE BODY user2.TestPackage AS FUNCTION MyFunction(Param1 IN TestType) RETURN TestType IS BEGIN RETURN Param1; END;END TestPackage;/-- Grant rights user1 (run with user2)GRANT ALL ON TestType TO User1 WITH GRANT OPTION;GRANT EXECUTE ON TestPackage TO User1 WITH GRANT OPTION;-- Call proc from User1declare tmp USER2.TestType; tmp2 USER2.TestType;begin tmp := USER2.TestType('Mr.Smith'); tmp2 := USER2.TESTPACKAGE.MYFUNCTION(tmp); dbms_output.put_line('tmp: ' || tmp.NEWATTRIB1); dbms_output.put_line('tmp2: ' || tmp2.NEWATTRIB1); end;
Please remember:Two types are never the same! If you use a type in a schema, you're not allowed to define a similar-type in another schema, to retrieve the object. You have to explicitly name the type in the other schema (=user2.type1).You have to grant rights to the schema/user which wants to use the type (in you example grant type- and package-privs).
As troubleshooting in an existing project, you could check it step-by-step:
- Logon with user1
Write some plsql which uses your type
declare tmp user2.type1;begin tmp := user2.type1('Mr.Smith'); -- if this works, your type-privs are correct.end;
Write some plsql which uses the package