Running PL/SQL Procedures in a Distributed Database
In the same way that DDL statements can be run on all shards in an Oracle Globally Distributed Database configuration, so too can certain Oracle-provided PL/SQL procedures.
These specific procedure calls behave as if they were sharded DDL statements, in that they are propagated to all shards, tracked by the catalog, and run whenever a new shard is added to a configuration.
All of the following procedures can act as if they were a sharded DDL statement.
-
Oracle Text
CTXSYSprocedures listed in Oracle Text Application Developer's Guide, Supported APIs in a Sharded Database -
Any procedure in the
DBMS_FGApackage -
Any procedure in the
DBMS_RLSpackage -
Any procedure in the
DBMS_REDACTpackage -
The following procedures from the
DBMS_STATSpackage:GATHER_INDEX_STATSGATHER_TABLE_STATSGATHER_SCHEMA_STATSGATHER_DATABASE_STATSGATHER_SYSTEM_STATS
-
The following procedures from the
DBMS_GOLDENGATE_ADMpackage:ADD_AUTO_CDRADD_AUTO_CDR_COLUMN_GROUPADD_AUTO_CDR_DELTA_RESALTER_AUTO_CDRALTER_AUTO_CDR_COLUMN_GROUPPURGE_TOMBSTONESREMOVE_AUTO_CDRREMOVE_AUTO_CDR_COLUMN_GROUPREMOVE_AUTO_CDR_DELTA_RES
To run one of the procedures in the same way as sharded DDL statements, do the following steps.
-
Connect to the shard catalog database using SQL*Plus as a database user with the
gsm_pooladmin_role. -
Enable sharding DDL using
ALTER SESSION ENABLE SHARD DDL. -
Run the target procedure using a sharding-specific PL/SQL procedure named
SYS.EXEC_SHARD_PLSQL.This procedure takes a single CLOB argument, which is a character string specifying a fully qualified procedure name and its arguments. Note that running the target procedure without using
EXEC_SHARD_PLSQLcauses the procedure to only be run on the shard catalog, and it is not propagated to all of the shards. Running the procedure without specifying the fully qualified name (for example,SYS.DBMS_RLS.ADD_POLICY) will result in an error.
For example, to run DBMS_RLS.ADD_POLICY on all shards, do the
following from SQL*Plus after enabling SHARD DLL.
exec sys.exec_shard_plsql('sys.dbms_rls.add_policy(object_schema =>
''testuser1'',
object_name => ''DEPARTMENTS'',
policy_name => ''dept_vpd_pol'',
function_schema => ''testuser1'',
policy_function => ''authorized_emps'',
statement_types => ''INSERT, UPDATE, DELETE, SELECT, INDEX'',
update_check => TRUE)'
) ;Take careful note of the need for double single-quotes inside the target procedure
call specification, because the call specification itself is a string
parameter to EXEC_SHARD_PLSQL.
If the target procedure runs correctly on the shard catalog database, it is queued for processing on all of the currently deployed shards. Any error in running the target procedure on the shard catalog is returned to the SQL*Plus session. Errors while running on the shards can be tracked in the same way they are for DDLs.