- STMT_t FAR* pstmt = (STMT_t*)hstmt;
-
- HPROC hproc = SQL_NULL_HPROC;
- RETCODE retcode = SQL_SUCCESS;
- int sqlstat = en_00000;
-
- if( hstmt == SQL_NULL_HSTMT
- || pstmt->hdbc == SQL_NULL_HDBC )
- {
- return SQL_INVALID_HANDLE;
- }
-
- /* check state */
- if( pstmt->asyn_on == en_NullProc )
- {
- /* not on asyn state */
- switch( pstmt->state )
- {
- case en_stmt_fetched:
- case en_stmt_xfetched:
- sqlstat = en_24000;
- break;
-
- case en_stmt_needdata:
- case en_stmt_mustput:
- case en_stmt_canput:
- sqlstat = en_S1010;
- break;
-
- default:
- break;
- }
- }
- else if( pstmt->asyn_on != en_Prepare )
- {
- /* asyn on other */
- sqlstat = en_S1010;
- }
-
- if( sqlstat != en_00000 )
- {
- PUSHSQLERR ( pstmt->herr, sqlstat );
-
- return SQL_ERROR;
- }
-
- if( szSqlStr == NULL )
- {
- PUSHSQLERR ( pstmt->herr, en_S1009 );
-
- return SQL_ERROR;
- }
-
- if( cbSqlStr < 0 && cbSqlStr != SQL_NTS )
- {
- PUSHSQLERR ( pstmt->herr, en_S1090 );
-
- return SQL_ERROR;
- }
-
- hproc = _iodbcdm_getproc( pstmt->hdbc, en_Prepare );
-
- if( hproc == SQL_NULL_HPROC )
- {
- PUSHSQLERR ( pstmt->herr, en_IM001 );
- return SQL_ERROR;
- }
-
- CALL_DRIVER ( pstmt->hdbc, retcode, hproc, en_Prepare, (
- pstmt->dhstmt, szSqlStr, cbSqlStr) )
-
-#if 0
- retcode = hproc ( pstmt->dhstmt, szSqlStr, cbSqlStr );
-#endif
-
- /* stmt state transition */
- if( pstmt->asyn_on == en_Prepare )
- {
- switch( retcode )
- {
- case SQL_SUCCESS:
- case SQL_SUCCESS_WITH_INFO:
- case SQL_ERROR:
- pstmt->asyn_on = en_NullProc;
- return retcode;
-
- case SQL_STILL_EXECUTING:
- default:
- return retcode;
- }
- }
-
- switch( retcode )
- {
- case SQL_STILL_EXECUTING:
- pstmt->asyn_on = en_Prepare;
- break;
-
- case SQL_SUCCESS:
- case SQL_SUCCESS_WITH_INFO:
- pstmt->state = en_stmt_prepared;
- pstmt->prep_state = 1;
- break;
-
- case SQL_ERROR:
- switch( pstmt->state )
- {
- case en_stmt_prepared:
- case en_stmt_executed:
- pstmt->state = en_stmt_allocated;
- pstmt->prep_state = 0;
- break;
-
- default:
- break;
- }
-
- default:
- break;
- }
-
- return retcode;
+ STMT_t FAR *pstmt = (STMT_t *) hstmt;
+
+ HPROC hproc = SQL_NULL_HPROC;
+ RETCODE retcode = SQL_SUCCESS;
+ int sqlstat = en_00000;
+
+ if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
+ {
+ return SQL_INVALID_HANDLE;
+ }
+
+ /* check state */
+ if (pstmt->asyn_on == en_NullProc)
+ {
+ /* not on asyn state */
+ switch (pstmt->state)
+ {
+ case en_stmt_fetched:
+ case en_stmt_xfetched:
+ sqlstat = en_24000;
+ break;
+
+ case en_stmt_needdata:
+ case en_stmt_mustput:
+ case en_stmt_canput:
+ sqlstat = en_S1010;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (pstmt->asyn_on != en_Prepare)
+ {
+ /* asyn on other */
+ sqlstat = en_S1010;
+ }
+
+ if (sqlstat != en_00000)
+ {
+ PUSHSQLERR (pstmt->herr, sqlstat);
+
+ return SQL_ERROR;
+ }
+
+ if (szSqlStr == NULL)
+ {
+ PUSHSQLERR (pstmt->herr, en_S1009);
+
+ return SQL_ERROR;
+ }
+
+ if (cbSqlStr < 0 && cbSqlStr != SQL_NTS)
+ {
+ PUSHSQLERR (pstmt->herr, en_S1090);
+
+ return SQL_ERROR;
+ }
+
+ hproc = _iodbcdm_getproc (pstmt->hdbc, en_Prepare);
+
+ if (hproc == SQL_NULL_HPROC)
+ {
+ PUSHSQLERR (pstmt->herr, en_IM001);
+ return SQL_ERROR;
+ }
+
+ CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Prepare,
+ (pstmt->dhstmt, szSqlStr, cbSqlStr))
+
+ /* stmt state transition */
+ if (pstmt->asyn_on == en_Prepare)
+ {
+ switch (retcode)
+ {
+ case SQL_SUCCESS:
+ case SQL_SUCCESS_WITH_INFO:
+ case SQL_ERROR:
+ pstmt->asyn_on = en_NullProc;
+ return retcode;
+
+ case SQL_STILL_EXECUTING:
+ default:
+ return retcode;
+ }
+ }
+
+ switch (retcode)
+ {
+ case SQL_STILL_EXECUTING:
+ pstmt->asyn_on = en_Prepare;
+ break;
+
+ case SQL_SUCCESS:
+ case SQL_SUCCESS_WITH_INFO:
+ pstmt->state = en_stmt_prepared;
+ pstmt->prep_state = 1;
+ break;
+
+ case SQL_ERROR:
+ switch (pstmt->state)
+ {
+ case en_stmt_prepared:
+ case en_stmt_executed:
+ pstmt->state = en_stmt_allocated;
+ pstmt->prep_state = 0;
+ break;
+
+ default:
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return retcode;