Gettting a SQLExtendedFetch Error?

I'm getting the following erro: S1106
[Sybase][ODBC Driver] An invalid fFetch Type value was specified.
in the SQLExtendedFetch() return value means:

S1106      Fetch type out of range      The value specified for the argument fFetchType was not equal to:
SQL_FETCH_NEXT
SQL_FETCH_FIRST
SQL_FETCH_LAST
SQL_FETCH_ PREV
SQL_FETCH_ABSOLUTE
SQL_FETCH_RELATIVE
SQL_FETCH_RESUME

Here is what my code is doing:

char sBuff[800];
char sSSN[10];
     
wsprintf( sBuff,
             "SELECT empl_ssn FROM employee WHERE empl_company = '%s' AND \
             empl_qtr = %ld AND empl_work_state = 'CT' OR empl_work_state = 'GU'",
             "873500", 199901 );
   
m_DBase->createHandle( &hScroll );
m_DBase->sql( hScroll, sBuff );
m_DBase->bindString( hScroll, 1, sSSN, 10 );
m_DBase->fetchEx( hScroll, SQL_FETCH_FIRST, nRecordCount );

which is a thin wrapper class.  
so createHandle is SQLAllocStmt()
sql is SQLExecDirect()
bindString just binds is SQLBindCol()

Here is the code for the fetchEx:
retCode = SQLExtendedFetch(hStmt, SQL_FETCH_FIRST, NULL, NULL, NULL);

Can any help explain what this error means and how it is caused and how to fix it.

Thanks


eric07Asked:
Who is Participating?
 
ajith_29Connect With a Mentor Commented:
hi eric,
Please do remove the where condition and run your sql statement
and  I have pasted the part I think is giving you the error.
empl_work_state = 'GU'",
  "873500", 199901
The last where clause is a problem I think please remove the where clause and then put one by one the where clause and then you will know the error.I am sure your where clause is producing that error.
Bye
Ajith
0
All Courses

From novice to tech pro — start learning today.