Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdpii\tdpii_distdbs009.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title>Tutorial: Running a Stored Procedure in a Remote Oracle Database</title> <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1 Build 005" /> <meta name="date" content="2009-06-04T17:1:1Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Tutorial: Running a Stored Procedure in a Remote Oracle Database" /> <meta name="relnum" content="11g Release 2 (11.2)" /> <meta name="partnum" content="E10703-01" /> <link rel="copyright" href="./dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> <link rel="stylesheet" href="./dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="tdpii_distdbs008.htm" title="Previous" type="text/html" /> <link rel="next" href="tdpii_distdbs010.htm" title="Next" type="text/html" /> <script src="./callback.js" type="text/javascript"></script> <noscript>Your browser does not support JavaScript. This help page requires JavaScript to render correctly.</noscript> </head> <body> <div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr valign="bottom"> <td align="left"></td> <td align="center"><a href="tdpii_distdbs008.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_distdbs010.htm"><img src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="BABFCFJJ" name="BABFCFJJ"></a><a id="TDPII024" name="TDPII024"></a></p> <div class="sect1"><!-- infolevel="all" infotype="General" --> <h1>Tutorial: Running a Stored Procedure in a Remote Oracle Database<a id="sthref65" name="sthref65"></a><a id="sthref66" name="sthref66"></a><a id="sthref67" name="sthref67"></a></h1> <a name="BEGIN" id="BEGIN"></a> <p>A <span class="bold">remote procedure call (RPC)</span> 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 <code>@</code><code><span class="codeinlineitalic">dblink</span></code> to the end of its name. The <code><span class="codeinlineitalic">dblink</span></code> 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.</p> <p>Meet the following conditions before performing the sample RPC in this topic:</p> <ul> <li> <p>Satisfy the prerequisites described in <a href="tdpii_distdbs006.htm#BABJDEED">"Preparing to Access and Modify Information in Multiple Oracle Databases"</a>.</p> </li> <li> <p>Create a database link from the local database to any remote database that contains a procedure or function that is being called. In the example in this topic, the <code>SYSTEM</code> user at the <code>ii1.example.com</code> database uses a database link that connects to the <code>SYSTEM</code> user at the <code>ii2.example.com</code> database. See <a href="tdpii_common_ii006.htm#BGBGIACD">"Tutorial: Creating a Database Link"</a> for information about creating such a database link.</p> </li> <li> <p>Ensure that the <code>hr</code> sample schema is installed on the remote database. The <code>hr</code> sample schema is installed by default with Oracle Database.</p> </li> </ul> <p>This topic uses <code>ii1.example.com</code> and <code>ii2.example.com</code> as sample databases. You can substitute any two databases in your environment that meet these conditions.</p> <p>For this example, assume the following:</p> <ul> <li> <p>A company keeps its human resources information in the <code>hr</code> schema at the <code>ii2.example.com</code> database.</p> </li> <li> <p>The <code>hr</code> schema does not exist at the local <code>ii1.example.com</code> database.</p> </li> <li> <p>When an employee leaves the company, a procedure called <code>add_job_history</code> in the <code>hr</code> schema inserts a row into the <code>hr.job_history</code> table. The row contains information about the history of the employee with the company.</p> </li> <li> <p>The employee with an <code>employee_id</code> of <code>127</code> is leaving the company.</p> </li> <li> <p>You want to connect to the <code>ii1.example.com</code> database and run the <code>add_job_history</code> procedure at the <code>ii2.example.com</code> database to record the job history for employee <code>127</code>.</p> </li> </ul> <p class="orderedlisttitle">To run an RPC to record the job history of the employee: </p> <ol> <li> <p>On a command line, open SQL*Plus and connect to the <code>ii1.example.com</code> database as the <code>SYSTEM</code> user.</p> <p>See <a href="topicid:ADMQS0361">Starting SQL*Plus and Connecting to the Database</a> for more information about starting SQL*Plus.</p> </li> <li> <p>Run the <code>add_job_history</code> procedure at the <code>ii2.example.com</code> database to record the job history of the employee:</p> <pre xml:space="preserve" class="oac_no_warn"> exec hr.add_job_history@ii2.example.com(127,'14-JAN-99','26-JUN-06','ST_CLERK',50); </pre></li> <li> <p>Commit the changes:</p> <pre xml:space="preserve" class="oac_no_warn"> COMMIT; </pre> <p>This step is not necessary if the remote procedure commits.</p> </li> <li> <p>Optionally, query the <code>hr.job_history</code> table at the <code>ii2.example.com</code> database to see the inserted row:</p> <pre xml:space="preserve" class="oac_no_warn"> SELECT * FROM hr.job_history@ii2.example.com ORDER BY employee_id; </pre> <p>The output will be similar to the following:</p> <pre xml:space="preserve" class="oac_no_warn"> <span class="bold">EMPLOYEE_ID START_DAT END_DATE JOB_ID DEPARTMENT_ID</span> <span class="bold">----------- --------- --------- ---------- -------------</span> <span class="bold"> 101 21-SEP-89 27-OCT-93 AC_ACCOUNT 110</span> <span class="bold"> 101 28-OCT-93 15-MAR-97 AC_MGR 110</span> <span class="bold"> 102 13-JAN-93 24-JUL-98 IT_PROG 60</span> <span class="bold"> 114 24-MAR-98 31-DEC-99 ST_CLERK 50</span> <span class="bold"> 122 01-JAN-99 31-DEC-99 ST_CLERK 50</span> <span class="bold"> 127 14-JAN-99 26-JUN-06 ST_CLERK 50</span> <span class="bold"> 176 24-MAR-98 31-DEC-98 SA_REP 80</span> <span class="bold"> 176 01-JAN-99 31-DEC-99 SA_MAN 80</span> <span class="bold"> 200 17-SEP-87 17-JUN-93 AD_ASST 90</span> <span class="bold"> 200 01-JUL-94 31-DEC-98 AC_ACCOUNT 90</span> <span class="bold"> 201 17-FEB-96 19-DEC-99 MK_REP 20</span> </pre> <p>Notice that the job history of the employee with an <code>employee_id</code> of <code>127</code> is recorded in the table.</p> </li> </ol> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdpii_intro2ii003.htm#CFHHAIGB">When to Access and Modify Information in Multiple Databases</a></p> <p><a href="tdpii_distdbs.htm#BABEFFBB">Accessing and Modifying Information in Multiple Databases</a></p> <p><a href="tdpii_distdbs007.htm#BABFJGFG">Tutorial: Querying Multiple Oracle Databases</a></p> <p><a href="tdpii_distdbs008.htm#BABCCCGB">Tutorial: Modifying Data in Multiple Oracle Databases</a></p> </div> </div> <!-- class="sect1" --> <!-- Start Footer --> <div class="footer"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr> <td align="left"><span class="copyrightlogo">Copyright © 2007, 2009, Oracle and/or its affiliates. All rights reserved.</span><br /> <a href="./dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> <td align="center"><a href="tdpii_distdbs008.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_distdbs010.htm"><img src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> </div> <!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de