Oracle by Example brandingUse DBMS_HS_PASSTHROUGH to Execute a Bulk Fetch

section 0Before You Begin

This 15-minute tutorial demonstrates how to declare a remote stored procedure and execute a bulk fetch of the data from the stored procedure using the DBMS_HS_PASSTHROUGH package.

Background

This tutorial demonstrates that you can send SQL statements directly to a remote foreign data source using the DBMS_HS_PASSTHROUGH PL/SQL package. This is useful when you want to perform an operation on the remote foreign data source and there is no equivalent Oracle SQL to do so.

Also, this tutorial uses a configured Oracle Database Gateway for SQL Server (dg4msql) and the Oracle Net listener that has an entry for it.

What Do You Need?


section 1Create a Database Link to the Gateway

Create a database link to your gateway.

CONNECT / AS SYSDBA;
Connected.
SET ECHO ON;
SET SERVEROUTPUT ON;
CREATE DATABASE LINK linkname CONNECT TO remote_username IDENTIFIED BY remote_password USING 'tnsentry_to_gateway'; Database link created.

For this tutorial:

  • The value for linkname is fdslink.
  • The value for remote_username and remote_password are supplied by you.
  • The value for tnsentry_to_gateway is dg4msql.


section 2Create a Table in the Remote Foreign Data Source

In order to create objects in the remote non-Oracle database, the user specified in the database link must have CREATE privileges granted.

Example: Create a Table in the Remote Foreign Data Source


section 3Populate the Table

Populate the table with sample data.

Example: Populate the Table


section 4Create a Stored Procedure

Create a stored procedure that reads data from the table and returns a result set.

Example: Create a Stored Procedure


section 5Create a REF CURSOR and Execute a Bulk Fetch

To execute a bulk fetch, you must first create a REF CURSOR. Once you have created the REF CURSOR, you can execute a bulk fetch.

Example: Create a REF CURSOR and Execute a Bulk Fetch


more informationWant to Learn More?