Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

11.2.3 Using an SQL connection to a distributed RD-node

This section explains use of an SQL connection to a distributed RD-node as the current SQL connection for accessing a remote database.

When an SQL connection to a distributed RD-node is used as the current SQL connection, only the databases at the current RD-node can be accessed.

Using an SQL-connection to a distributed RD-node offers the following advantage: It is not necessary to use an RD-node name as a modifier or a table alias, as is required when the default SQL connection is used for accessing a remote database. The table name and procedure name defined in the current RD-node can be specified directly in the SQL statement.

Organization of this subsection
(1) Setting the current SQL connection using a CONNECT statement with RD-node specification
(2) Setting the current SQL connection using a SET CONNECTION statement

(1) Setting the current SQL connection using a CONNECT statement with RD-node specification

Because the current SQL connection becomes the SQL connection to the distributed RD-node when the CONNECT statement with RD-node specification is executed, the SQL connection to the distributed RD-node can be used immediately.

Usage example
In the example shown below, the current SQL connection specified by the CONNECT statement with RD-node specification is used to retrieve data from the inventory table titled MANAGER.STOCK at the distributed RD-node named RDNODE10.
CONNECT TO RDNODE10 USER:USER2 USING :PSWD2SELECT SQUANTITY INTO :QUANTITY FROM MANAGER.STOCK WHERE PCODE='302S'

(2) Setting the current SQL connection using a SET CONNECTION statement

If the current SQL connection is not the SQL connection to the distributed RD-node that is to be accessed, the current SQL connection can be changed with the SET CONNECTION statement. The SQL connection to the distributed RD-node must be created before the SET CONNECTION statement is issued.

Usage example
In the example shown below, the SET CONNECTION statement is used to set the distributed RD-node named RDNODE10 as the current RD-node, and then the procedure named MANAGER.PROC10 at that RD-node is called.
SET CONNECTION RDNODE10CALL MANAGER.PROC10 (arguments)