I wrote a simple pro * c program to test the connection to the database. The code:
int main()
{
char *conn_string = "IDA/IDA@DBISPSS";
int x = 10;
printf("value of x is before db connection %d\n",x);
printf(" conn_string %s \n",conn_string);
EXEC SQL CONNECT :conn_string;
EXEC SQL SELECT 1 INTO :x FROM DUAL;
printf("value of x is %d\n",x);
return 0;
}
The following commands I ran to create the exectuable (test_connection) code pro * c
proc test_connection.pc
cc -I${ORACLE_HOME}/precomp/public -c test_connection.c
cc test_connection.o -o test_connection -L$ORACLE_HOME/lib -lclntsh
and when I ran test_connection exe, the output
value of x is before db connection 10
conn_string IDA/IDA@DBISPSS
Segmentation fault
But the same code works well on a different Linux machine and a Solaris machine.
Why is there a segmentation error?
source
share