Home » Developer & Programmer » Precompilers, OCI & OCCI » C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB (C++ version11, AIX 6100-07-03-1207)
C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #577997] Fri, 22 February 2013 09:00 Go to next message
najmaaaa
Messages: 6
Registered: February 2013
Junior Member
Hi,

Previously we had 32 bit C++. Now, we have migrated it to 64 bit. And our C++ programs interact with Oracle 10g DB.

Our C++ program was working fine with 32 bit. But once after we migrate to 64 bit we are facing problem with one program which does FETCH(EXEC SQL FETCH SUBP1 INTO :newTabRec;) from Oracle DB. ie,

We exit from a for loop in the C++ program when we get NOT FOUND(sqlca.sqlcode=1403) on executing the FETCH statement.

The sqlcode generated for NOT FOUND scenario is 1403. But, once after moving to 64 bit C++, we do not see the sqlcode 1403 instead we are seeing a different code 7124089117159473.

As the sqlcode is not 1403, our program does not exit from the for loop and goes on an infinite loop.

Am I missing anything that makes me to not get the exact sqlcode?
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #577999 is a reply to message #577997] Fri, 22 February 2013 09:39 Go to previous messageGo to next message
Michel Cadot
Messages: 59145
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Did you recompile and relink your program?

Regards
Michel
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578001 is a reply to message #577999] Fri, 22 February 2013 10:17 Go to previous messageGo to next message
najmaaaa
Messages: 6
Registered: February 2013
Junior Member
Yes Michel. I did recompilation and relinking by including the option for 64 bit. I used -m64 while doing precompilation and used -q64 while relinking.
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578005 is a reply to message #578001] Fri, 22 February 2013 10:46 Go to previous messageGo to next message
Michel Cadot
Messages: 59145
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
So you have to post the code that fails.

Before, Please read How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags.
Use the "Preview Message" or "Preview Quick Reply" button to verify.

Regards
Michel
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578009 is a reply to message #578005] Fri, 22 February 2013 12:32 Go to previous messageGo to next message
najmaaaa
Messages: 6
Registered: February 2013
Junior Member
Hello Michel,

In the below code, we are looking for sqlca.sqlcode == 1403 and when it is met, we exit the loop. But, once after this upgrade, we do not get the sqlcode 1403. We are getting a different number(7124089117159473). Hence, it does not break the loop.

/* EXEC SQL WHENEVER NOT FOUND DO break; */
for (;;)
{
memset(newTabRec.INPUT.arr, 0, sizeof(newTabRec.INPUT.arr));
newTabRec.INPUT.len = 0;
newTabRec.INPUT.arr[newTabRec.INPUT.len] = '\0';

memset(newTabRec.OUTPUT.arr, 0, sizeof(newTabRec.OUTPUT.arr));
newTabRec.OUTPUT.len = 0;
newTabRec.OUTPUT.arr[newTabRec.OUTPUT.len] = '\0';

/* EXEC SQL FETCH SUBP1 INTO :newTabRec; */

{
struct sqlexd sqlstm;
sqlorat((void **)0, &sqlctx, &oraca);
sqlstm.sqlvsn = 12;
sqlstm.arrsiz = 4;
sqlstm.sqladtp = &sqladt;
sqlstm.sqltdsp = &sqltds;
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )100;
sqlstm.selerr = (unsigned short)1;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)256;
sqlstm.occurs = (unsigned int )0;
sqlstm.sqfoff = ( int )0;
sqlstm.sqfmod = (unsigned int )2;
sqlstm.sqhstv[0] = (unsigned char *)&newTabRec.INPUT;
sqlstm.sqhstl[0] = (unsigned long )4002;
sqlstm.sqhsts[0] = ( int )0;
sqlstm.sqindv[0] = ( short *)0;
sqlstm.sqinds[0] = ( int )0;
sqlstm.sqharm[0] = (unsigned long )0;
sqlstm.sqadto[0] = (unsigned short )0;
sqlstm.sqtdso[0] = (unsigned short )0;
sqlstm.sqhstv[1] = (unsigned char *)&newTabRec.OUTPUT;
sqlstm.sqhstl[1] = (unsigned long )4002;
sqlstm.sqhsts[1] = ( int )0;
sqlstm.sqindv[1] = ( short *)0;
sqlstm.sqinds[1] = ( int )0;
sqlstm.sqharm[1] = (unsigned long )0;
sqlstm.sqadto[1] = (unsigned short )0;
sqlstm.sqtdso[1] = (unsigned short )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqphss = sqlstm.sqhsts;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqpins = sqlstm.sqinds;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlstm.sqpadto = sqlstm.sqadto;
sqlstm.sqptdso = sqlstm.sqtdso;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
if (sqlca.sqlcode == 1403) break;
if (sqlca.sqlcode < 0) (retVal=sql_error("ORACLE error:"));
}


newTabRec.INPUT.arr[newTabRec.INPUT.len] = '\0';
newTabRec.OUTPUT.arr[newTabRec.OUTPUT.len] = '\0';

inpRetVal = string((char *)newTabRec.INPUT.arr);
outRetVal = string((char *)newTabRec.OUTPUT.arr);

subsTabValues[inpRetVal] = outRetVal;

if(!retVal)
break;
}
/* EXEC SQL CLOSE SUBP1; */
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578012 is a reply to message #578009] Fri, 22 February 2013 12:52 Go to previous messageGo to next message
Michel Cadot
Messages: 59145
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Is this your actual code or is this the code generated by Oracle precompiler?

Regards
Michel
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578013 is a reply to message #578012] Fri, 22 February 2013 12:55 Go to previous messageGo to next message
najmaaaa
Messages: 6
Registered: February 2013
Junior Member
That was the code generated by the compiler.
Below is our actual code.

EXEC SQL WHENEVER NOT FOUND DO break;
for (;;)
{
memset(newTabRec.INPUT.arr, 0, sizeof(newTabRec.INPUT.arr));
newTabRec.INPUT.len = 0;
newTabRec.INPUT.arr[newTabRec.INPUT.len] = '\0';

memset(newTabRec.OUTPUT.arr, 0, sizeof(newTabRec.OUTPUT.arr));
newTabRec.OUTPUT.len = 0;
newTabRec.OUTPUT.arr[newTabRec.OUTPUT.len] = '\0';

EXEC SQL FETCH SUBP1 INTO :newTabRec;

newTabRec.INPUT.arr[newTabRec.INPUT.len] = '\0';
newTabRec.OUTPUT.arr[newTabRec.OUTPUT.len] = '\0';

inpRetVal = string((char *)newTabRec.INPUT.arr);
outRetVal = string((char *)newTabRec.OUTPUT.arr);

subsTabValues[inpRetVal] = outRetVal;

if(!retVal)
break;
}
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578014 is a reply to message #578013] Fri, 22 February 2013 13:00 Go to previous messageGo to next message
najmaaaa
Messages: 6
Registered: February 2013
Junior Member
If I add a condition like below in the code segment, then it exits the for loop and executes perfectly fine.

if(sqlca.sqlcode == 7124089117159473)
break;
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578598 is a reply to message #578012] Fri, 01 March 2013 14:10 Go to previous messageGo to next message
najmaaaa
Messages: 6
Registered: February 2013
Junior Member
Hi Michel,

It got fixed. The variables sqlabc, sqlcode and sqlerrd in the header file sqlca.h were long previously. After changing all these to int, it started working.

Thanks & Regards,
Najma
Re: C++ - migrated from 32 bit to 64 bit and getting unrelated sqlcode while dealing with Oracle DB [message #578599 is a reply to message #578598] Fri, 01 March 2013 14:48 Go to previous message
Michel Cadot
Messages: 59145
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Thanks for the feedback.

Regards
Michel
Previous Topic: OCI+kerberos authentication
Next Topic: "ORA-03106" error on trying to retrieve CLOB columns whose default value is set to EMPTY_CLOB().
Goto Forum:
  


Current Time: Sat Sep 20 02:59:44 CDT 2014

Total time taken to generate the page: 0.09788 seconds