- CALL_DRIVER ( pstmt->hdbc, retcode, hproc, en_ColAttributes, (
- pstmt->dhstmt,
- icol,
- fDescType,
- rgbDesc,
- cbDescMax,
- pcbDesc,
- pfDesc) )
-
-#if 0
- retcode = hproc(pstmt->dhstmt,
- icol,
- fDescType,
- rgbDesc,
- cbDescMax,
- pcbDesc,
- pfDesc );
-#endif
-
- /* state transition */
- if( pstmt->asyn_on == en_ColAttributes )
- {
- switch( retcode )
- {
- case SQL_SUCCESS:
- case SQL_SUCCESS_WITH_INFO:
- case SQL_ERROR:
- pstmt->asyn_on = en_NullProc;
- break;
-
- default:
- return retcode;
- }
- }
+RETCODE SQL_API
+SQLDescribeCol (
+ HSTMT hstmt,
+ UWORD icol,
+ UCHAR FAR * szColName,
+ SWORD cbColNameMax,
+ SWORD FAR * pcbColName,
+ SWORD FAR * pfSqlType,
+ UDWORD FAR * pcbColDef,
+ SWORD FAR * pibScale,
+ SWORD FAR * pfNullable)
+{
+ STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
+ HPROC hproc;
+ RETCODE retcode;
+ int sqlstat = en_00000;
+
+ if (hstmt == SQL_NULL_HSTMT
+ || pstmt->hdbc == SQL_NULL_HDBC)
+ {
+ return SQL_INVALID_HANDLE;
+ }
+
+ /* check arguments */
+ if (icol == 0)
+ {
+ sqlstat = en_S1002;
+ }
+ else if (cbColNameMax < 0)
+ {
+ sqlstat = en_S1090;
+ }
+
+ if (sqlstat != en_00000)
+ {
+ PUSHSQLERR (pstmt->herr, sqlstat);
+
+ return SQL_ERROR;
+ }
+
+ /* check state */
+ if (pstmt->asyn_on == en_NullProc)
+ {
+ if (pstmt->asyn_on == en_stmt_allocated
+ || pstmt->asyn_on >= en_stmt_needdata)
+ {
+ sqlstat = en_S1010;
+ }
+ }
+ else if (pstmt->asyn_on != en_DescribeCol)
+ {
+ sqlstat = en_S1010;
+ }
+
+ if (sqlstat != en_00000)
+ {
+ PUSHSQLERR (pstmt->herr, sqlstat);
+
+ return SQL_ERROR;
+ }
+
+ /* call driver */
+ hproc = _iodbcdm_getproc (pstmt->hdbc, en_DescribeCol);
+
+ if (hproc == SQL_NULL_HPROC)
+ {
+ PUSHSQLERR (pstmt->herr, en_IM001);
+
+ return SQL_ERROR;
+ }
+
+ CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_DescribeCol,
+ (pstmt->dhstmt, icol, szColName, cbColNameMax, pcbColName,
+ pfSqlType, pcbColDef, pibScale, pfNullable))
+
+ /* state transition */
+ if (pstmt->asyn_on == en_DescribeCol)
+ {
+ switch (retcode)
+ {
+ case SQL_SUCCESS:
+ case SQL_SUCCESS_WITH_INFO:
+ case SQL_ERROR:
+ pstmt->asyn_on = en_NullProc;
+ break;
+
+ default:
+ return retcode;
+ }
+ }
+
+ switch (pstmt->state)
+ {
+ case en_stmt_prepared:
+ case en_stmt_cursoropen:
+ case en_stmt_fetched:
+ case en_stmt_xfetched:
+ if (retcode == SQL_STILL_EXECUTING)
+ {
+ pstmt->asyn_on = en_DescribeCol;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return retcode;
+}