Connectivity problem through Pro*C++

From: <daraacc_at_my-dejanews.com>
Date: Tue, 28 Jul 1998 18:57:21 GMT
Message-ID: <6pl6uh$gi0$1_at_nnrp1.dejanews.com>



I have a OraclePro*C++ Sample program running on Solaris platform. The program pre-compiles and compiles well when the EXEC SQL CONNECT statement in it is commented. But it errors out when we Compile it keepin the EXEC SQL CONNECT statement. When we try to run it it just rund till this statement and gives a Solaris core dump.
The Program code is :

/*

  • proto.pc *
  • Connects to the TC database and gets the required
  • data record. Uses indicator
  • variables (in an indicator struct) to determine
  • if the values are NULL. * */

#include <stdio.h>
#include <string.h>

/* Define constants for VARCHAR lengths. */

#define     UNAME_LEN      20
#define     PWD_LEN        40
#define     DAT_LEN        120

VARCHAR     username[UNAME_LEN];  /* VARCHAR is an Oracle-supplied struct */
VARCHAR     password[PWD_LEN];    /* varchar can be in lower case also. */

/* Define a host structure for the output values of a SELECT statement. */
struct
{

    VARCHAR geis_inter_data[DAT_LEN];
    INT rec_key;
} interfdatarec;

/* Define an indicator struct to correspond to the host output struct. */
struct
{

    short     geis_inter_data_ind;
    short     rec_key_ind;

} interfdatarec_ind;

/* Input host variable. */

int total_queried;

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

/* Declare error handling function. */

void sql_error();

main()
{

    char temp_char[32];

/* Connect to ORACLE--

  • Copy the username into the VARCHAR. */ strncpy((char *) username.arr, "SCOTT", UNAME_LEN);

/* Set the length component of the VARCHAR. */

    username.len = strlen((char *) username.arr);

/* Copy the password. */

    strncpy((char *) password.arr, "TIGER", PWD_LEN);     password.len = strlen((char *) password.arr);
/* Register sql_error() as the error handler. */

    EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");

/* 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; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error occurs on this statement Executable gives a core dump when reaching this statement
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

/* Break out of the loop when a

  • 1403 ("No data found") condition occurs. */ EXEC SQL WHENEVER NOT FOUND DO break; for (;;) { EXEC SQL SELECT geis_inter_data, rec_key INTO :interfdatarec INDICATOR :interfdatarec_ind FROM ATT_GEISEDI_INTER;
        }

/* Disconnect from ORACLE. */

    EXEC SQL COMMIT WORK RELEASE;
    exit(0);
}

void
sql_error(msg)
char *msg;
{

    char err_msg[128];
    int buf_len, msg_len;

    EXEC SQL WHENEVER SQLERROR CONTINUE;     printf("\n%s\n", msg);
    buf_len = sizeof (err_msg);
    sqlglm(err_msg, &buf_len, &msg_len);     printf("%.*s\n", msg_len, err_msg);

    EXEC SQL ROLLBACK RELEASE;
    exit(1);
}

Any kind of help would be appreciated.

Thanks in advance

Darayush

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Tue Jul 28 1998 - 20:57:21 CEST

Original text of this message