ORA 1001 [message #365164] |
Thu, 15 June 2000 14:12 |
Srivatsan Parthasarathy
Messages: 1 Registered: June 2000
|
Junior Member |
|
|
Hi,
I am having a problem when using Cursors in Pro*C.
The cursor is to return one record.The following is the scenario
Open cursor
for(; ;) /* Infinite times */
{
fetch
if error code = 1403 break;
---OTHER
---PROCESSING
)
close cursor
I am getting the first record correctly. When it goes back to the loop for the second record instead of breaking off it gives an ORA error 1001.
I am not opening an alredy open cursor, nor closing a cursor which is closed.
Any help will be greatly appreciated.
Thanks in advance
--Vatsa
|
|
|
Re: ORA 1001 [message #365169 is a reply to message #365164] |
Mon, 19 June 2000 10:02 |
Rob
Messages: 70 Registered: January 2000
|
Member |
|
|
Hello,
There are many possible returncodes when fetching from a cursor but commonly it ends with a SQLEndFetch but when something is wrong then there is another code. I will give you the following code, we use it to check every sql statement.
void CMApp::SQLCheck(CString SourceFile,int SourceLine)
{
// Set SQLOK if all went OK and nothing happened
if (sqlca.sqlcode == 0 || sqlca.sqlcode == -1405)
{
SQLError = SQLOK;
return;
}
// Set SQLEndFetch if end of last fetch
if (sqlca.sqlcode == 1403)
{
SQLError = SQLEndFetch;
return;
}
// Something happened, log and display message
CString ErrorText;
char SQLmsg[[ 512 + 1]];
unsigned int buf_len = sizeof( SQLmsg ), msg_len;
sqlglm( SQLmsg, &buf_len, &msg_len );
SQLmsg msg_len = '\0';
ErrorText.Format( "SQL Fout %05i in bestand '%s', in regel %i: %s.",
-sqlca.sqlcode, (PCSTR) SourceFile, SourceLine, SQLmsg );
Log(LTDatabaseError,0,"%s",(PCSTR)ErrorText);
m_pMainWnd->MessageBox(ErrorText,AfxGetAppName(),MB_OK|MB_ICONSTOP|MB_APPLMODAL);
// It was not fatal, set SQLWarning
SQLError = SQLWarning;
return;
// It was fatal, stop the program !!!
}
it gives you an explination about wath's going wrong .
Call it imediately after you've executed the sql statement. ( so directly after the fetch)
I hope it helps you
|
|
|