Re: Pro*C Problem

From: John Strange <jstrange_at_imtn.dsccc.com>
Date: 13 Sep 2001 12:26:30 -0500
Message-ID: <3ba0ec46_at_news.alcatel.com>


Here is a snippet of my connect code.

err_msg is a global string in all my programs and will contain the error message from oracle calls.

err_msg[0] = '\0' ; /* null last error msg */

EXEC SQL INCLUDE SQLCA ; EXEC SQL CONNECT :appidpwd ;

               /******** null fill id/pw and pw strings ***********/ lint_ptr = memset ((char *) appidpwd.arr, '\0', sizeof ((char *) appidpwd.arr)); lint_ptr = memset ((char *) appid_pwd.arr, '\0', sizeof ((char *) appid_pwd.arr));

if (sqlca.sqlcode != 0) /* check 4 oracle error */ {
  rtn_code = sprintf (err_msg, "%s", sqlca.sqlerrm.sqlerrmc) ; }

return (sqlca.sqlcode) ;

Jennifer (jblankenship_at_osc.uscg.mil) wrote:
: I have an open TAR with Oracle about this. However, the TAR is 9 days
: old and they have not been able to help me resolve this. I am very
: frustrated right now.

: The servers that are currently in production are running Oracle 7.3.4
: in an HPUX 10.20 environment. We have bought new servers and have
: Oracle 8.1.6 installed on them in an HPUX 11.0 environment - 64 bit.
: So, we are recompiling all of the old code to run on the new servers.
: All of my code has compiled without errors, however, it does not run
: correctly.

: The code is a text-based menu. Users login to the Unix box via a
: telnet session and make their selection from the menu. All of the menu
: routines are select statements - no updating or deleting data from the
: database. However, I can not get the menu to connect to the database.
: It just hangs. No error message at all.

: I have combed MetaLink and Google trying all relevant suggestions I
: could find.

: ** The $ORACLE_SID is lower case in all places: .profile, oratab,
: control files, initSID.ora, tnsnames.ora, listener.ora,
: ** The $ORACLE_HOME is set correctly and is the absolute path.
: ** Permissions for Oracle executable are 6755 and for tnslsnr are
: 4755.
: ** Umask is set to 022 for all database users.
: ** The file system is not mounted with no set uid.
: ** I can connect to the database via SQL*Plus with no problems.
: ** I can issue a tnsping and receive data back.

: I can compile the Pro*C sample programs and they work just fine. I
: have actually copied the code from sample1.pc and pasted it into my
: code, in hopes of it working. No such luck. Since the code is
: identical, I would think it would have to be something outside of the
: code - the Makefile, for instance. The Oracle tech on my TAR doesn't
: think so. However, the Oracle sample code is compiled with the
: demo_proc.mk file. My code is compiled with a modified version of the
: Oracle Makefile.

: Is there anything that anyone can think of that maybe was deleted from
: the modified Makefile that needs to be added back in? Or is there
: something else all together that is missing? I am pulling my hair out!
: Any help is appreciated!

: Below is the function that is connecting to the database. I have
: hardcoded in the username and password, thinking maybe my call to the
: file for that information was having a problem - but that wasn't it.
: It prints out the printf statement that comes before the EXEC SQL
: CONNECT statement, but not the one following it. I assume that it is
: hanging on the EXEC SQL CONNECT statement.

: #define SQLCA_STORAGE_CLASS extern

: /* Define constants for VARCHAR lengths. */
: #define UNAME_LEN 20
: #define PWD_LEN 40

: /* Declare variables. No declare section is
: needed if MODE=ORACLE. */
: VARCHAR username[UNAME_LEN]; /* VARCHAR is an Oracle-supplied
: struct */
: varchar password[PWD_LEN]; /* varchar can be in lower case
: also. */

: /* Include the SQL Communications Area.
: You can use #include or EXEC SQL INCLUDE. */
: #include <sqlca.h>

: /****************************************************************************/
: /* Function: oraconnect(connectfile)
: */
: /* Purpose: Connects to ORACLE RDBMS using the Username and
: Password */
: /* specified in the connectfile. Each AMVER process has
: its own */
: /* connectfile containing an oracle user id and password.
: The */
: /* proc_code is the IEW process number. The subproc_code
: can */
: /* be used by the calling module to indicate the function
: from */
: /* where this function was called for traceback.
: */
: /****************************************************************************/
: /****************************************************************************/

: short oraconnect(connectfile,proc_code, subproc_code)

: char connectfile[80];
: short proc_code; /* Process identification codes */
: short subproc_code; /* from IEW document */
: {
: char temp_char[32];

: /* Connect to ORACLE--
: * Copy the username into the VARCHAR.
: */
: strncpy((char *) username.arr, "OUR_USERNAME", UNAME_LEN);

: /* Set the length component of the VARCHAR. */
: username.len =
: (unsigned short) strlen((char *) username.arr);

: /* Copy the password. */
: strncpy((char *) password.arr, "XXXXXXX", PWD_LEN);
: password.len =
: (unsigned short) strlen((char *) password.arr);
: /* Register sql_error() as the error handler. */
: EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");

: printf("\nGetting ready to connect to ORACLE as user: %s\n",
: username.arr);

: /* Connect to ORACLE. Program will call sql_error()
: * if an error occurs when connecting to the default database.
: */
: EXEC SQL CONNECT :username IDENTIFIED BY :password;

: printf("\nConnected to ORACLE as user: %s\n", username.arr);

: return(SUCCEED);

: logonerr:
: return(sqlerr(proc_code,subproc_code,11));
: }

--
While Alcatel may claim ownership of all my ideas (on or off the job),
Alcatel does not claim any responsibility for them. Warranty expired when u
opened this article and I will not be responsible for its contents or use.
Received on Thu Sep 13 2001 - 19:26:30 CEST

Original text of this message