Re: How to specify the "AT DB_NAME" in Connect Remote Database in Por*C

From: DanHW <danhw_at_aol.com>
Date: 03 Dec 1999 05:56:21 GMT
Message-ID: <19991203005621.26891.00000232_at_ng-cr1.aol.com>


>Hi,
>
>Some background: One of my friend projects needs to connect to multiple
>Oracle Database in Pro*C: query one database and insert/update another.
>
>Oracle Doc's indicates use "AT DB_NAME USING ..." or "AT :db_name USING
>..." in connection. But I did not make it work. The following is the
>code fragments modified for sample1.pc
>
>1:
> ...
> char *mydb_string = "my_tnsname";
>
>EXEC SQL DECLARE DB_NAME DATABASE;
> ...
>/* In main() */
>...
>EXEC SQL CONNECT :username
> IDENTIFIED BY :password
> AT DB_NAME
> USING :mydb_string;
>
>...
>
>2:
>...
>char *mydb = "my_oraccle_sid";
>char *mydb_string = "my_tnsname";
>
> ...
>/* In main() */
>...
>EXEC SQL CONNECT :username
> IDENTIFIED BY :password
> AT :mydb
> USING :mydb_string;
>
>
>But I got the same error:
>
>$ sample1
>
>Connected to ORACLE as user: SCOTT/TIGER
>
>Enter employee number (0 to quit): 7788
>
>ORACLE error--
>
>ORA-01012: not logged on
>
>If removed the AT ... line, sampel1 worked fine to connect the remote
>database.
>
>
>Q: What "String" or "Identifier" I should give after "AT" to make the
>
>remote connection?
>
>My Env:
>
>Oracle: 8.05/7.3
>Sun Solaris 2.6/AIX 4.1
>
>
>Thanks

The syntax to connect to an instance with a TNS name "mysystem", with scott/tiger would be

create database link mylink connect to scott identified by tiger using 'mysystem';

<I think that is correct...the connect string has to be quoted>

Once you have created the dblink, you can do

select * from tab_at_mylink;

(or create synonyms to do it)

Hope this helps
Dan Hekimian-Williams Received on Fri Dec 03 1999 - 06:56:21 CET

Original text of this message