hall@fornax.UUCP (Gary Hall) (01/10/90)
I am having trouble connecting to a remote Oracle database (Ver 6.0) from a
Pro*C program using SQL*Net TCP/IP. I have no trouble making the connection
with SQL*Plus or SQL*DBA.
Here is the code:
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR uid[30];
VARCHAR pwd[30];
VARCHAR host1[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca.h;
main()
{
strcpy(uid.arr,"userid");
uid.len = strlen(uid.arr);
strcpy(pwd.arr,"password");
pwd.len = strlen(pwd.arr);
strcpy(host1.arr,"t:servername:aaa");
host1.len = strlen(host1.arr);
EXEC SQL DECLARE AAA DATABASE;
EXEC SQL CONNECT :uid IDENTIFIED BY :pwd
AT AAA USING :host1;
printf("returncode:%d\n",sqlca.sqlcode);
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
The result is: returncode:-6105 (6105 means "cannot connect to remote host-
remote host is unknown". (The output is printed after a wait of 90 secs.)
The string "t:servername:aaa" works fine with SQL*Plus etc.
Oracle tech support faxed me this working code :
/* ... The program requires ... a remote database specification setup called
REMOTE that points to the remote node/CPU. ... */
...
VARCHAR node_id[40]; /* Node ID (eg. DECNet node name) */
...
/* Set up the Node id ('REMOTE') for the remote database ... the "D" specifies
DECNet */
strcpy(node_id.arr, "D:REMOTE");
...
EXEC SQL DECLARE DB_REMOTE DATABASE;
...
EXEC SQL CONNECT :username IDENTIFIED BY :password
AT DB_REMOTE USING :node_id;
...
Questions:
1. Why does the Oracle REMOTE specification only refer to a protocol
and a host, and not to a database? (This doesn't work for me.)
2. What's wrong with what I'm doing?
All suggestions will be gratefully received.