Home » Developer & Programmer » Precompilers, OCI & OCCI » error "ORA-01012: not logged in" when exec sql
icon5.gif  error "ORA-01012: not logged in" when exec sql [message #126325] Sun, 03 July 2005 12:11 Go to next message
danfol
Messages: 1
Registered: July 2005
Junior Member
Hi all,
Need some serious help here. I have a Pro*C/C++ program on AIX which connects to the database and i have to select a table in it. The connection method returns successful, but when the subsequent method attempts to select data from it, the error "ORA-01012: not logged in" appeared. What happened? What I should I do? Please help.
I precompiler the prog from the other server,and copy the runnable file to the server which reporing the error.The two server have the same env for system and the oracle.The prog worked fine on the precompilered server.Do I need to precompile the progs on the new server instead of copying the runnable files to the new server?(There is no precompiler env on the new server for security cause)why?The two servers have the same envs.
Thanks a lot in advance
Here are some code:
void main(int argc,char **argv)
{              int          iRet;
               long          pid;
          int          pidNum,pidMax;
for(pidNum=0;pidNumÔľúpidMax;pidNum++)
        {
                pid=fork();
                if(pid==0)
                {
                        iRet=DealData();
                        exit(0);
                }
                else if(pid>0)
                {
                        continue;
                }
                else
                {
                        printf("\n************************************\n\n");
                        printf("[%s] %ssetup failed:create instance failed[%d][%s].\n",ShowTimer(),PRO_NAME,errno,strerror(errno));                        
                        printf("\n************************************\n\n");
                        break;
                }
        }  
          if((pidNum==pidMax)&&(pid>0))
          {
                  printf("[%s] %ssetup success\n",ShowTimer(),PRO_NAME);
          }else{
                  printf("[%s] %ssetup failed\n",ShowTimer(),PRO_NAME);
          }
}

int DealData()
{
        if((ret=ConnectDatabase())!=0)
        {
            wrtlog("connect db failed\n");
            printf("\n************************************\n\n");
                printf("[%s] %sconnect db failed[%d].\n",ShowTimer(),PRO_NAME,ret);                        
                printf("\n************************************\n\n");
                     logoff();        
            return -1;
        }
        wrttmpdb();
}
int ConnectDatabase( )
{
        EXEC SQL CONNECT :username IDENTIFIED BY :password;
        if ( sqlca.sqlcode )
                printf( "Connect DataBase Fault %ld \n", sqlca.sqlcode );
        return sqlca.sqlcode;
}
int wrttmpdb()
{
EXEC SQL SELECT KEY_SEQ.NEXTVAL INTO :key_seq
                FROM DUAL;
        if(SQLCODE!=0)
                WRTLOGDB,"select key_seq.nextval fail.\n");

}

When exec "select key_sql" reporting the "ORA-01012".
Re: error "ORA-01012: not logged in" when exec sql [message #128926 is a reply to message #126325] Thu, 21 July 2005 04:59 Go to previous message
palanivel_pk
Messages: 4
Registered: July 2005
Location: chennai
Junior Member
The problem is due to the following query which is in int wrttmpdb(), could not able to connect to the database

EXEC SQL SELECT KEY_SEQ.NEXTVAL INTO :key_seq FROM DUAL;


Try with this:

EXEC SQL AT DB_NAME SELECT KEY_SEQ.NEXTVAL INTO :key_seq FROM DUAL;



Vel
Previous Topic: PROBLEM WITH SQLCXT
Next Topic: OCI Logon/Logoff Threading issue
Goto Forum:
  


Current Time: Fri Oct 23 22:48:15 CDT 2020