Error ORA-01012: not logged on

From: GePs <spammaquesta_at_email.it>
Date: 26 Oct 2005 06:06:25 -0700
Message-ID: <1130331985.036136.316960_at_z14g2000cwz.googlegroups.com>



Hello everyone!
I'm new on this group, and my english is not very fine, so I make excuses myself before...
I must write a program with OCI libs, and I followed manuals and examples found on OTN to reach a sufficient skill to write my own program.
First I wrote a test program in a single main() function, and all works fine!
Now I'm trying to split my main() in several functions (like db_init(), db_connect(), db_query(), db_close()), but here I've a problem! The program which is calling that functions is like the following one (I simplified the calls, bat the substance is the same. The functions are defined in another source code)

#include <db.h>
main() {
db_struct *db;
db = db_init();

db_connect(db);
db_query(db);
db_close(db);

}

Here short descriptions of the functions: In db_init I call OCIEnvCreate() and OCIHandleAlloc() for an error handle. All handles are persistent and stored in the struct pointed by *db: the type db_struct is defined in the header file db.h, and contains all pointers to the OCI handles used by the program (OCIEnv, OCIError, etc...)
db_connect() calls all functions needed for a user authenticated connection to db: several OCIHandleAlloc() and OCIAttrSet() for server and service context handles, OCIServerAttach() and finally OCISessionBegin(). The sequence of calls is the same of my prevoious test main(), where all worked fine.
db_query() allocates and prepares properly the statement handle, and here I have the error in subject (ORA-01012: not logged on): it happens when I try the OCIStmtExecute(). It seems that the user session on db is lost between the calls to the funtions db_connect() and db_query(). It sound very strange to me: the parameters are passed correcltly, otherwise also the passage from db_init() to db_connect() shouldn't work!
I repeat that the same calls and parameters passage works in the first single-main() test program (the only difference is in the presence of db_struct: in test main() I had separate pointers variables)!!! I checked all the calls and they seem correct to me, I can't see where my errors are, if there are!
Please, help me if you can!
Thank you, GePs Received on Wed Oct 26 2005 - 15:06:25 CEST

Original text of this message