Home » Developer & Programmer » Precompilers, OCI & OCCI » Compile pro*c file with "-DDAEMON -DBACKGROUND" option on Solaris (Pro*C, Oracle 10g, Solaris 10)
icon9.gif   Compile pro*c file with "-DDAEMON -DBACKGROUND" option on Solaris [message #345500] Wed, 03 September 2008 21:03 Go to next message
cwchan
Messages: 2
Registered: September 2008
Junior Member
Hello:

I am using Solaris 10, Oracle 10g, and Sun One Studio compiler version 8.

I have 2 Pro*C program (ABC.pc and XYZ.pc), both use the following command for DB connections.

=== Start of Code (Common) ===

printf("Start");

exec sql connect / at DBNAME ;

if (sqlca.sqlcode != 0)
{
printf("Fail");
return -1;
}

printf("Success");


=== End of Code (Common) ===

Both program work fine in Oracle 9i and Solaris 8
However, after upgrade to Oracle 10g and Solaris 10
ABC cannot print out anything and directly jump back to parent function.
While XYZ success fully connect to database and perform PL/SQL.

Here is the cpp compiler files:

=== Start of Compile file (ABC) ===
ORACLE_HOME=/oracle/product/10.2
ORACLIB=$ORACLE_HOME/lib32
PROCLIB=$ORACLE_HOME/precomp/lib

ABCLIB = <ABC daemon library path>
/opt/SUNWspro/prod/bin/CC ABC.cpp -library=iostream -library=rwtools7 -o $ABCLIB/ABCdaemon -I$PROCINCLUDE -I$SRC -L$ORACLE_HOME/lib32 -R/$ORACLE_HOME/lib32 -DDAEMON -DBACKGROUND

=== End of Compile file (ABC) ===


=== Start of Compile file (XYZ) ===
ORACLE_HOME=/oracle/product/10.2
ORACLIB=$ORACLE_HOME/lib32
PROCLIB=$ORACLE_HOME/precomp/lib

XYZLIB = <XYZ library path>
XYZSRC = <XYZ source path>

CPPLIB=/opt/SUNWspro/prod/include/CC/rw7/rw
/opt/SUNWspro/prod/bin/CC XYZ.cpp -library=iostream -library=rwtools7 -o $XYZLIB/XYZ -I$XYZSRC/XYZ -I$PROCINCLUDE -I$CPPLIB -L$ORACLE_HOME/lib32 -R/$ORACLE_HOME/lib32

=== End of Compile file (XYZ) ===

The difference is "-DDAEMON -DBACKGROUND" in the compilation file.
Also ABC is a child process while XYZ is master process.
Is there any idea for this?

Thanks ahead for any assistance.
Re: Compile pro*c file with "-DDAEMON -DBACKGROUND" option on Solaris [message #345940 is a reply to message #345500] Fri, 05 September 2008 06:31 Go to previous message
cwchan
Messages: 2
Registered: September 2008
Junior Member
Here is some update, it turns out that is not related to the -DDAEMON -DBACKGROUND option, and is still unable to connect to Oracle.

source

==========================
#include "genConst.h"
#include "genInclude.h"

EXEC SQL INCLUDE SQLCA;

int main (int argc, char* argv[])
{
exec sql begin declare section;
char luid20;
char dbname20;
int lnCnt = 0;
exec sql end declare section;

printf("Testmain.cpp : main() Testing 1 \n");

strcpy(luid, "/");
strcpy(dbname, "TESTDB");

printf("Testmain.cpp : main() Testing 2 \n");

exec sql connect :luid at :dbname;

printf("Testmain.cpp : main() Testing 3 \n");

EXEC SQL
EXECUTE
BEGIN
select count(*)
into :lnCnt
from testtable;
END;
END-EXEC;

printf("Testmain.cpp : main() Testing 4 \n");
if (sqlca.sqlcode != 0)
{
printf("Testmain.cpp : main() Testing 5 %i \n", lnCnt);
printf("%.*s \n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
return -1;
}
else
{
printf("Testmain.cpp : main() Testing 6 %i \n", lnCnt);
}

printf("Testmain.cpp : main() Testing 7 \n");
return 0;
}

compilation command

==========================================================
$ORACLE_HOME/bin/proc $TEST_HOME/Testmain CODE=CPP CPP_SUFFIX=cpp SQLCHECK=SEMANTICS SYS_INCLUDE=test INCLUDE=/usr/include USERID=test/test@$ORASID
/opt/SUNWspro/prod/bin/CC Testmain.cpp -library=iostream -library=rwtools7 -o $TESTLIB/test -I$TESTSRC/test -I$PROCINCLUDE -I$CPPLIB -L$ORACLE_HOME/lib32 -lnsl -lclntsh -R/$ORACLE_HOME/lib32

Output
===============================
Testmain.cpp : main() Testing 1
Testmain.cpp : main() Testing 2
Testmain.cpp : main() Testing 3
Testmain.cpp : main() Testing 4
Testmain.cpp : main() Testing 5 0
ORA-01012: not logged on

So, anyone has any idea how to resolve this error? So that "ORA-01012"
does not show up?
Previous Topic: OCI Multithread in HPUX
Next Topic: OCI - ORA-1403 & ORA-1405 Errors
Goto Forum:
  


Current Time: Tue Dec 17 20:02:05 CST 2024