Oracle8 : CONNECT to non-default database -> ORA-12154 (Server Error Message)
From: Alex Vinokur <alexander.vinokur_at_telrad.co.il>
Date: Tue, 05 Oct 1999 12:07:40 GMT
Message-ID: <7tcpm6$pfd$1_at_nnrp1.deja.com>
Hi,
VARCHAR dynstmt3[80];
Pro*C/C++ Precompiler Programmer's Guide Release 8.0
A58233-01
4. Advanced Pro*C/C++ Applications
Connecting to Oracle8
### The USING clause specifies the network, machine, and database to be ### associated with DB_NAME. Later, SQL statements using the AT clause (with
### DB_NAME) are executed at the database specified by db_string. ###
Date: Tue, 05 Oct 1999 12:07:40 GMT
Message-ID: <7tcpm6$pfd$1_at_nnrp1.deja.com>
Hi,
///////////////////////////////////////////////[Quoted] 1. Error message
I have got the following error message.
//===========================================
ORA-12154: TNS:could not resolve service name
in "..."
on line 97 of demo6.pc.
//===========================================
Here is a relevant piece of the code (Pro*C/C++).
What (and where) is wrong?
//===========================================
// file demo6.pc
void main()
{
/* Declare the program host variables. */
[Quoted] char *username = "aaa"; char *password = "bbb"; char *db_name = "ddd"; char *db_string = "NYNON"; asciz dynstmt1; char dynstmt2[10];
VARCHAR dynstmt3[80];
[ --- omitted --- ]
EXEC SQL CONNECT :username // Line#97 IDENTIFIED BY :password AT :db_name USING :db_string;puts("\nConnected to ORACLE.\n");
[ --- omitted --- ]
}
//===========================================
- Oracle 8.0.5
- Prro*C/C++
- SunOS 5.6
///////////////////////////////////////////////2. Questions
Here is a a piece from Oracle8 Documentation and my question.
Pro*C/C++ Precompiler Programmer's Guide Release 8.0
A58233-01
4. Advanced Pro*C/C++ Applications
Connecting to Oracle8
### ### Single Explicit Connections ### ### In the following example, you connect to a single non-defaultdatabase at a
### remote node: ### ### /* declare needed host variables */ ### char username[10] = "scott"; ### char password[10] = "tiger"; ### char db_string[20] = "NYNON"; ### ### /* give the database connection a unique name */ ### EXEC SQL DECLARE DB_NAME DATABASE; ### ### /* connect to the non-default database */ ### EXEC SQL CONNECT :username IDENTIFIED BY :password ### AT DB_NAME USING :db_string; ### ### The identifiers in this example serve the following purposes: ### ### * The host variables username and password identify a valid user. ### * The host variable db_string contains the Net8 syntax for connecting to ### a non-default database at a remote node. In the example above db_string == "NYNON". 1. If db_string value is not arbitrary, what is this value connected with? 2. Is there any connection between db_string value (i.e. "NYNON") and the tnsnames.ora configuration file? 2. Is there any connection between db_string value (i.e. "NYNON") and another files? 4. What do I have to do yet to use db_string (== ""NYNON", for instance). ### * The undeclared identifier DB_NAME names a non-default connection; it is ### an identifier used by Oracle, not a host or program variable. ###
### The USING clause specifies the network, machine, and database to be ### associated with DB_NAME. Later, SQL statements using the AT clause (with
### DB_NAME) are executed at the database specified by db_string. ###
Thanks in advance, Alex
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Tue Oct 05 1999 - 14:07:40 CEST