We have a package SCHEMA.MYPACKAGE with a procedure SCHEMA.MYPACKAGE.GETDATA that calls a sql macro SCHEMA.SQLMACROFUNCTION that exists within the same schema but outside the package. The macro is called within a select statement and qualified by schema name even though it's within the same schema, like this:
SELECT col1,col2,col3
FROM SCHEMA.SQLMACROFUNCTION(param1, param2, param3)
ORDER BY col1 DESC;
The problem is that when anything invalidates the package (for example, adding a column to a table the package depends on) and the next procedure call tries to auto-compile the package as Oracle is supposed to do, the compile fails with
PLS-00201: identifier 'SQLMACROFUNCTION' must be declared
leaving the package in an invalid state until it's manually compiled with
ALTER PACKAGE SCHEMA.MYPACKAGE COMPILE;
which always succeeds.
Anyone have an explanation for this behavior? I considered permissions, but the package and the sql_macro function are in the same schema. I considered function name qualification, but it's already called with schemaname.objectname. Also, and I can't corroborate with evidence from Oracle documentation, but I read somewhere that functions (in this case a sql_macro) have to be executed in order to validate the code, but an auto-compile only parses the code, which might explain.
There are obvious workarounds to this issue (substituting the function code into the procedure in place of the function call resolves the auto-compile issue), but I'm curious to understand why it's happening and am interested in some documentation, if it's out there.
Thanks in advance.