How can I make a connection to a remote database using SQL 400 specifying the database name and the machine where it is?
You can use the SQL CONNECT statement to access any remote database that supports the Open Group DRDA standard.
You need to use the ADDRDBDIRE CL to add an entry and the TCP/IP address of the Remote Database server and assign it a name that will be used on the SQL Connect statement.
The application code would look something like the following: CONNECT TO remotedb1 user using 'passwd'
SELECT col1, col2 FROM remotetablename ORDER BY col1
You can look at the Distributed Database Programming guide in the iSeries InfoCenter for more details on remote database access.
MORE INFORMATION ON THIS TOPIC
Check out this Search400.com Featured Topic: Database issues resolved
Search400.com's targeted search engine: Get relevant information on DB2/400.
The Best Web Links: Tips, tutorials and more.
Dig Deeper on DB2 UDB (universal databases)
Related Q&A from Kent Milligan
To solve the SQL error -321 on IBM i6.1, use the new values statement to overcome the error. If you are using an older release, declare a cursor ... Continue Reading
When working with DB2 files with columns that have both short and long names, there is no option choose which column names are returned via ODBC ... Continue Reading
When developing tables in a parent-child relationship, use a primary key and a foreign key along with a unique ID to make your database easier to ... Continue Reading