![]() |
| | #1 | |
| Registered User Join Date: Mar 2006 Location: In my Parent House
Posts: 34
| functions seems not to exit from a certain code block here is a sample of my log file Quote:
I have no idea how to fix this, can anyone help me or atleast give some insight on what is happening here. BTW: I'm using MVC6 , win2k and my database is DB2. The test I've made here is removing my logon to database function, so when I try to access the function there should be an error log. here is the code Code: int getData()
{
int error = 0;
WriteToLog("Inside getData");
EXEC SQL WHENEVER NOT FOUND GO TO nodata;
EXEC SQL WHENEVER SQLERROR GO TO exit;
EXEC SQL DECLARE cur1 CURSOR FOR
SELECT
DESK,
SYMBOL,
RM_TIME,
PRODUCT,
RM_DATE
FROM QPNL.TABLE_MANAGEMENT
where RM_DATE = (current date) ;
EXEC SQL OPEN cur1;
do {
EXEC SQL FETCH cur1 INTO
:desk,
:symbol,
:sql_time,
:product,
:sql_date;
setData(); // set the retreive data into string/character
if (buildAndSendMsg() == 1)
{
goto exit;
}
} while (1);
nodata:
WriteToLog("CURSOR HAS REACHED END OF TABLE.");
EXEC SQL CLOSE cur1;
return 0;
exit://the function does not exit on this part....it will only continue to print/write to log the ff details.
WriteToLog("============================"); // use for log tracking....
SQLError("SELECT",SQLCODE,&sqlca) ;
EXEC SQL CLOSE cur1;
return 1; //
}
Code: int SQLError( char *Function, int err, struct sqlca *capointer )
{
//char buf[ 32 ] ;
char sqlState[ 1024 ] ;
char errorMsg[ 1024 ] ;
short rc ;
char temp[500];
if( err ) {
if (!(strcmp("SELECT",Function)==0 && err == 100)){
sprintf( temp,"%s Error: SQL return code of %d.", Function, err ) ;
WriteToLog(temp);
if ( err != -803 ) {
rc = sqlogstt( sqlState, sizeof(sqlState), 80, capointer->sqlstate ) ;
if( sqlaintp( errorMsg, sizeof( errorMsg ), 80, capointer ) > 0 ) {
sprintf(temp,"%s : SQL Error message='%s'.",Function,errorMsg ) ;
WriteToLog(temp);
}
if( !rc ) {
sprintf( temp,"%sSQL State='%s'.",Function,sqlState ) ;
WriteToLog(temp);
}
}
}
}else {
if(memcmp(Function, "UPDATE", 6)==0){
CommitDB();
//WriteToLog("UPDATE of data is successful.");
}
if(memcmp(Function, "INSERT", 6)==0){
CommitDB();
WriteToLog("INSERTION of data is successful.");
}
if(memcmp(Function, "DELETE", 6)==0){
CommitDB();
WriteToLog("DELETION of data is successful.");
}
if(memcmp(Function, "CONNECT",7)==0){
WriteToLog("Connection to database has been established.");
}
}
return( err ) ;
}
I appologize if my english seems bad, it's not my native language. Regards, jaro | |
| jaro is offline | |
| | #2 |
| Registered User Join Date: Mar 2006 Location: In my Parent House
Posts: 34
| Hi again, I've already found the solution to my problem. I just made some modification. here the code. Code: int getData()
{
int error = 0;
WriteToLog("Inside getData");
EXEC SQL WHENEVER NOT FOUND GO TO nodata;
EXEC SQL WHENEVER SQLERROR GO TO exit;
EXEC SQL DECLARE cur1 CURSOR FOR
SELECT
DESK,
SYMBOL,
RM_TIME,
PRODUCT,
RM_DATE
FROM QPNL.TABLE_MANAGEMENT
where RM_DATE = (current date) ;
EXEC SQL OPEN cur1;
do {
EXEC SQL FETCH cur1 INTO
:desk,
:symbol,
:sql_time,
:product,
:sql_date;
setData(); // set the retreive data into string/character
if (buildAndSendMsg() == 1)
{
goto exit;
}
} while (sqlca.sqlcode == 0);
EXEC SQL WHENEVER SQLERROR CONTINUE; ///
nodata:
WriteToLog("CURSOR HAS REACHED END OF TABLE.");
EXEC SQL CLOSE cur1;
return 0;
exit://the function does not exit on this part....it will only continue to print/write to log the ff details.
WriteToLog("============================"); // use for log tracking....
SQLError("SELECT",SQLCODE,&sqlca) ;
EXEC SQL CLOSE cur1;
EXEC SQL WHENEVER SQLERROR CONTINUE; ///
return 1; //
}
Regards, Jaro |
| jaro is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Odd memory leaks | Bubba | C++ Programming | 11 | 05-25-2006 12:56 AM |
| Dynamic array of pointers | csisz3r | C Programming | 8 | 09-25-2005 02:06 PM |
| HUGE fps jump | DavidP | Game Programming | 23 | 07-01-2004 10:36 AM |
| << !! Posting Code? Read this First !! >> | kermi3 | Game Programming | 0 | 10-14-2002 01:27 PM |
| Who will map the scan code (inserted by VKD_Force_keys) to virtual key code? | Unregistered | Windows Programming | 0 | 02-21-2002 06:05 PM |