As the title says, how do I connect to a given database in Oracle's Pro C? I don't want the connection for Oracle database but for some other database.
How do I connect to a database using Pro*C?
15.1k views Asked by suvitha At
3
There are 3 answers
3
On
From the documentation available here and in more detail here it looks like you can embed a CONNECT
statement directly in your code.
To quote the first article, a simplified connect statement would be:
EXEC SQL CONNECT { :user IDENTIFIED BY :oldpswd | :usr_psw }
[[ AT { dbname | :host_variable }] USING :connect_string ]
[ {ALTER AUTHORIZATION :newpswd | IN { SYSDBA | SYSOPER } MODE} ] ;
0
On
Relevant answer here if you want to connect with oracle-pro-c, using an oracle-wallet.
Connecting to a database in Pro C using Oracle Wallet
Works great to have a wallet, and provide empty strings for :userId
and :userPassword
.
EXEC SQL CONNECT :mptyStr IDENTIFIED BY :mptyStr AT :ORACLE_SID;
You use the
exec sql connect
statement in your C code:If you want to connect to a non-Oracle database, you will probably have to use the
at
version of the command:and set up a database link in Oracle so that it can pass requests through to the other DBMS.
DBMS' like DB2 provide transparent gateways which can give you this facility without having to go through ODBC. It depends on which DBMS you're targeting as to how you'd go about setting this up.