Re: Explicit Connections in Pro*C

From: Scott Urman <surman_at_oracle.com>
Date: 1996/05/09
Message-ID: <4mtmq8$o37_at_inet-nntp-gw-1.us.oracle.com>#1/1


In article <Pine.SUN.3.91.960509153654.26663A-100000_at_explorer.csc.com>, Will Jones <wjones14_at_explorer.csc.com> writes:
|>
|> We have a C program with embedded SQL developed with Pro*C. We
|> also have multiple instances of Oracle on our server. If the user has
|> his ORACLE_SID environmental variable set to the correct instance, the
|> program connects and works fine. If not, he gets an "Oracle not
|> available" message and no connection.
|>
|> Our current connect statement is like:
|>
|> EXEC SQL CONNECT :username IDENTIFIED BY :password;
|>
|> where the user is prompted for the Oracle logon ID and password. Can the
|> instance of Oracle be specified here as well?

You have two options here. The first is to use the CONNECT statement as you have it now. This will use the environment to determine which database instance to connect to (the ORACLE_SID variable). So you could do an explicit setenv(ORACLE_SID=<instance name>); before the CONNECT, to indicate the instance.

The second option is to use a connect string. You would have to have SQL*Net installed and configured for this. Something like

EXEC SQL CONNECT :username IDENTIFIED BY :password USING :connect_string;

where connect_string is a valid SQL*Net connect string for your database.

|>
|>
|> --
|> Bill Jones e-mail addresses:
|> Computer Sciences Corp. (work) wjones14_at_csc.com
|> Norwich, Connecticut (play) billj_at_mindport.net
|> (203) 823-2168
|>
 

-- 
------------------------------------------------------------------------
Scott Urman            Oracle Corporation           surman_at_us.oracle.com
------------------------------------------------------------------------
Author of _Oracle PL/SQL Programming_ ISBN 0-07-882176-2
Published by Oracle Press - http://www.osborne.com/oracle/index.htm
------------------------------------------------------------------------
"The opinions expressed here are my own, and are not necessarily that of
 Oracle Corporation"
------------------------------------------------------------------------
Received on Thu May 09 1996 - 00:00:00 CEST

Original text of this message