Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: connection problem in Pro*c

Re: connection problem in Pro*c

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 24 Dec 1998 19:20:33 GMT
Message-ID: <36839342.9277810@192.86.155.100>


A copy of this was sent to scip6125_at_leonis.nus.edu.sg (Zhao Fu) (if that email address didn't require changing) On 24 Dec 1998 07:01:35 GMT, you wrote:

>I am running the sample1 file from $ORACLE_HOME/precomp/demo/ on Sun
>Unix workstation, however I couldn't connect to the oracle database on
>system. Later, I found that our connection setting is a non-default
>connection via Net8. So, I referred to the manual and made the
>following change to the code:
>
>************************************************************************
>char username[10] = "scott";
>char password[10] = "tiger";
>char db_string[20] = "mcora"; /* my code, "mcora" is the SID*/
>EXEC SQL DECLARE DB_NAME DATABASE; /* my code*/
>EXEC SQL CONNECT :username IDENTIFIED BY :password AT DB_NAME USING
>:db_string; /* I appended the AT ... USING ... phrase*/
>************************************************************************
>
>However, when I ran the program, it seemed that I could connect to the
>database, but I couldn't execute any SQL command after that(e.g.
>SELECT).
>The error code is ORA-01012: not logged on. The following is the output
>message:
>

You've added 2 concepts to this connect:

USING :db_string is for specifying a remote database. AT DB_DBNAME is in support of >1 connection from a single program to different databases. If you use AT_DBNAME in the connect, you must use it in the cursors and such as well (otherwise, they are using the non-connected default connection).....

I think you just want to use:

EXEC SQL CONNECT :user IDENTIFIED BY :pass USING :db_string;

or more simply:

EXEC SQL CONNECT :user_pass_db_string

where :user_pass_db_string = "username/password_at_databasename" like you would give to sqlplus....

>Connected to ORACLE as user: scott
>
>Enter employee number (0 to quit): 2345
>
>ORACLE error--
>
>ORA-01012: not logged on
>
>I wonder if it is a still problem with the Oracle connection. Could
>anybody give me some advice?
>
>TIA
  Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Dec 24 1998 - 13:20:33 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US