Hello Team,
I think this is a SQLcl Project bug, or at least an export logic issue. I'm currently on the latest version at the moment:
Oracle SQLDeveloper Command-Line (SQLcl) version: 26.1.2.0 build: 26.1.2.132.1334
Please take a look:
In a SQLcl Project, project/application schemas are already known from the project configuration file, for example:
"schemas" : [ "CLA_APEX", "CLA_PUBLIC", "CLA_UTILITIES" ],
However, when I run SQLcl Project export as an installer/deployer account, SQLcl appears to attempt an ORDS schema export for the currently connected user instead of the schemas listed in the project configuration.
In my case, the connected user is CLA_DEPLOYER. This is an installer account with elevated deployment privileges. It is intentionally not one of the project schemas, and it is also intentionally not REST-enabled.
During project export, SQLcl runs something like this ( according to debug) :
select * from (
SELECT ords_metadata.ords_export.export_schema() out,
'ORDS_SCHEMA'
EXPORT_TYPE
FROM dual) where 1=1
--- filters ---
and (export_type in ('ORDS_SCHEMA')) --<-- project.filters
This fails because ords_export.export_schema() tries to export ORDS metadata for the current schema, which is CLA_DEPLOYER:
Failed to export ords due to ORA-20012: Schema not REST enabled : CLA_DEPLOYER
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT", line 222
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT", line 146
ORA-06512: at "ORDS_METADATA.ORDS_SECURITY_INTERNAL", line 306
ORA-06512: at "ORDS_METADATA.ORDS_SECURITY_INTERNAL", line 294
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT_INTERNAL", line 176
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT_INTERNAL", line 1366
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT", line 127
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT", line 157
ORA-06512: at "ORDS_METADATA.ORDS_EXPORT", line 215
There are two issues here.
-
First, this error is only visible when project export is run with debug output enabled. Without debug output, SQLcl appears to silently skip this part / do nothing. If ORDS export fails, the error should be reported even without debug logging.
-
Second, I do not think SQLcl Project should attempt ORDS export for the current connected user unless the current user is actually one of the configured project schemas. It does not do it for tables or views, so why to do it for ORDS? The schemas to export are already defined in the project configuration.
There is already ORDS functionality available to export another schema explicitly, for example:
select ords_export_admin.export_schema(
p_schema => 'CLA_APEX'
) out
from dual;
So the SQLcl Project ORDS export logic could probably be:
- Iterate through schemas listed in the SQLcl Project configuration.
- For each schema:
- If the current connected user is the schema being exported, use the current
ords_export.export_schema() logic.
- If the current connected user is different from the schema being exported, use
ords_export_admin.export_schema(p_schema => ...).
- If ORDS export fails for any schema, report the failure clearly even when debug output is not enabled.
This would support both common setups:
- running project export while connected directly as the project schema;
- running project export as a separate installer/deployer account, which is a common deployment setup.
The current behavior is especially confusing because SQLcl Project already knows the configured project schemas, but ORDS export still appears to target the connected installer schema instead.
Best,
Alex