Example 1: Replicating to an Oracle replicate database

The user wants to replicate a stored procedure defined by the following PL/SQL:

CREATE PROCEDURE boolproc (a IN BOOLEAN, b INT) AS
BEGIN
   IF (a = true) THEN
      DBMS_OUTPUT.PUT_LINE('True');
   ELSE
      DBMS_OUTPUT.PUT_LINE('False or NULL');
   ENDIF;
END;

The user manually creates a replication definition on Replication Server using the following RCL:

create function replication definition ra$xxx_boolproc
with primary at myprimary.pdb
with all functions named boolproc (
@"a" rs_oracle_decimal
@"b" rs_oracle_decimal )
searchable parameters(@"a", @"b")
send standby all parameters

NoteIf the Replication Agent pdb_auto_create_repdefs configuration parameter is set to true, a replication definition will be created automatically.

The user then marks the stored procedure for replication:

pdb_setrepproc boolproc, mark

The user creates a function string on Replication Server:

create function string ra$xxx_boolproc.boolproc
for rs_oracle_function_class
output language 
'begin execute immediate "begin ra_user.boolproc
(?a!param?=1,?b!param?);;end;;";;end;;'
go

The user then creates a subscription on Replication Server for the replication definition:

create subscription sub_intproc
for ra$xxx_boolproc
with replicate at myreplicate.rdb
go

The stored procedure will be replicated when it is executed at the primary database:

EXECUTE boolproc(true,1);