Your browser does not support JavaScript. This help page requires JavaScript to render correctly.
Skip Headers
Previous
Previous
 
Next
Next

Tutorial: Running a Stored Procedure in a Remote Oracle Database

A remote procedure call (RPC) runs a procedure or function at a remote database. An RPC performs any work defined in the remote procedure. To run a remote procedure or function, you can identify the remote procedure or function by appending @dblink to the end of its name. The dblink is a database link to the database that contains the remote procedure or function. You can also create a synonym that points to the remote procedure or function.

Meet the following conditions before performing the sample RPC in this topic:

This topic uses ii1.example.com and ii2.example.com as sample databases. You can substitute any two databases in your environment that meet these conditions.

For this example, assume the following:

To run an RPC to record the job history of the employee: 

  1. On a command line, open SQL*Plus and connect to the ii1.example.com database as the SYSTEM user.

    See Starting SQL*Plus and Connecting to the Database for more information about starting SQL*Plus.

  2. Run the add_job_history procedure at the ii2.example.com database to record the job history of the employee:

    exec hr.add_job_history@ii2.example.com(127,'14-JAN-99','26-JUN-06','ST_CLERK',50);
    
  3. Commit the changes:

    COMMIT;
    

    This step is not necessary if the remote procedure commits.

  4. Optionally, query the hr.job_history table at the ii2.example.com database to see the inserted row:

    SELECT * FROM hr.job_history@ii2.example.com ORDER BY employee_id;
    

    The output will be similar to the following:

    EMPLOYEE_ID START_DAT END_DATE  JOB_ID     DEPARTMENT_ID
    ----------- --------- --------- ---------- -------------
            101 21-SEP-89 27-OCT-93 AC_ACCOUNT           110
            101 28-OCT-93 15-MAR-97 AC_MGR               110
            102 13-JAN-93 24-JUL-98 IT_PROG               60
            114 24-MAR-98 31-DEC-99 ST_CLERK              50
            122 01-JAN-99 31-DEC-99 ST_CLERK              50
            127 14-JAN-99 26-JUN-06 ST_CLERK              50
            176 24-MAR-98 31-DEC-98 SA_REP                80
            176 01-JAN-99 31-DEC-99 SA_MAN                80
            200 17-SEP-87 17-JUN-93 AD_ASST               90
            200 01-JUL-94 31-DEC-98 AC_ACCOUNT            90
            201 17-FEB-96 19-DEC-99 MK_REP                20
    

    Notice that the job history of the employee with an employee_id of 127 is recorded in the table.

Related Topics

When to Access and Modify Information in Multiple Databases

Accessing and Modifying Information in Multiple Databases

Tutorial: Querying Multiple Oracle Databases

Tutorial: Modifying Data in Multiple Oracle Databases