]>
git.saurik.com Git - wxWidgets.git/blob - src/iodbc/result.c
   6  *  Prepare for getting query result 
   8  *  The iODBC driver manager. 
  10  *  Copyright (C) 1995 by Ke Jin <kejin@empress.com>  
  12  *  This library is free software; you can redistribute it and/or 
  13  *  modify it under the terms of the GNU Library General Public 
  14  *  License as published by the Free Software Foundation; either 
  15  *  version 2 of the License, or (at your option) any later version. 
  17  *  This library is distributed in the hope that it will be useful, 
  18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
  20  *  Library General Public License for more details. 
  22  *  You should have received a copy of the GNU Library General Public 
  23  *  License along with this library; if not, write to the Free 
  24  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  48     SDWORD FAR 
* pcbValue
) 
  50   STMT_t FAR 
*pstmt 
= (STMT_t FAR 
*) hstmt
; 
  51   HPROC hproc 
= SQL_NULL_HPROC
; 
  54   if (hstmt 
== SQL_NULL_HSTMT 
|| pstmt
->hdbc 
== SQL_NULL_HDBC
) 
  56       return SQL_INVALID_HANDLE
; 
  83        PUSHSQLERR (pstmt
->herr
, en_S1003
); 
  89       PUSHSQLERR (pstmt
->herr
, en_S1090
); 
  95   if (pstmt
->state 
> en_stmt_needdata 
|| pstmt
->asyn_on 
!= en_NullProc
) 
  97       PUSHSQLERR (pstmt
->herr
, en_S1010
); 
 101   /* call driver's function */ 
 102   hproc 
= _iodbcdm_getproc (pstmt
->hdbc
, en_BindCol
); 
 104   if (hproc 
== SQL_NULL_HPROC
) 
 106       PUSHSQLERR (pstmt
->herr
, en_IM001
); 
 111   CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_BindCol
, 
 112     (pstmt
->dhstmt
, icol
, fCType
, rgbValue
, cbValueMax
, pcbValue
)) 
 121     UCHAR FAR 
* szCursor
, 
 123     SWORD FAR 
* pcbCursor
) 
 125   STMT_t FAR 
*pstmt 
= (STMT_t FAR 
*) hstmt
; 
 129   if (hstmt 
== SQL_NULL_HSTMT 
|| pstmt
->hdbc 
== SQL_NULL_HDBC
) 
 131       return SQL_INVALID_HANDLE
; 
 135   if (cbCursorMax 
< (SWORD
) 0) 
 137       PUSHSQLERR (pstmt
->herr
, en_S1090
); 
 143   if (pstmt
->state 
>= en_stmt_needdata 
|| pstmt
->asyn_on 
!= en_NullProc
) 
 145       PUSHSQLERR (pstmt
->herr
, en_S1010
); 
 150   if (pstmt
->state 
< en_stmt_cursoropen
 
 151       && pstmt
->cursor_state 
== en_stmt_cursor_no
) 
 153       PUSHSQLERR (pstmt
->herr
, en_S1015
); 
 158   /* call driver's function */ 
 159   hproc 
= _iodbcdm_getproc (pstmt
->hdbc
, en_GetCursorName
); 
 161   if (hproc 
== SQL_NULL_HPROC
) 
 163       PUSHSQLERR (pstmt
->herr
, en_IM001
); 
 168   CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_GetCursorName
, 
 169     (pstmt
->dhstmt
, szCursor
, cbCursorMax
, pcbCursor
)) 
 180   STMT_t FAR 
*pstmt 
= (STMT_t FAR 
*) hstmt
; 
 184   if (hstmt 
== SQL_NULL_HSTMT 
|| pstmt
->hdbc 
== SQL_NULL_HDBC
) 
 186       return SQL_INVALID_HANDLE
; 
 190   if (pstmt
->state 
>= en_stmt_needdata
 
 191       || pstmt
->state 
<= en_stmt_prepared
 
 192       || pstmt
->asyn_on 
!= en_NullProc
) 
 194       PUSHSQLERR (pstmt
->herr
, en_S1010
); 
 200   hproc 
= _iodbcdm_getproc (pstmt
->hdbc
, en_RowCount
); 
 202   if (hproc 
== SQL_NULL_HPROC
) 
 204       PUSHSQLERR (pstmt
->herr
, en_IM001
); 
 209   CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_RowCount
, 
 210     (pstmt
->dhstmt
, pcrow
)) 
 221   STMT_t FAR 
*pstmt 
= (STMT_t FAR 
*) hstmt
; 
 226   if (hstmt 
== SQL_NULL_HSTMT 
|| pstmt
->hdbc 
== SQL_NULL_HDBC
) 
 228       return SQL_INVALID_HANDLE
; 
 232   if (pstmt
->asyn_on 
== en_NullProc
) 
 234       if (pstmt
->state 
== en_stmt_allocated
 
 235           || pstmt
->state 
>= en_stmt_needdata
) 
 237           PUSHSQLERR (pstmt
->herr
, en_S1010
); 
 241   else if (pstmt
->asyn_on 
!= en_NumResultCols
) 
 243       PUSHSQLERR (pstmt
->herr
, en_S1010
); 
 249   hproc 
= _iodbcdm_getproc (pstmt
->hdbc
, en_NumResultCols
); 
 251   if (hproc 
== SQL_NULL_HPROC
) 
 253       PUSHSQLERR (pstmt
->herr
, en_IM001
); 
 258   CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_NumResultCols
, 
 259     (pstmt
->dhstmt
, &ccol
)) 
 261   /* state transition */ 
 262   if (pstmt
->asyn_on 
== en_NumResultCols
) 
 267          case SQL_SUCCESS_WITH_INFO
: 
 269            pstmt
->asyn_on 
= en_NullProc
; 
 271          case SQL_STILL_EXECUTING
: 
 280      case SQL_SUCCESS_WITH_INFO
: 
 283      case SQL_STILL_EXECUTING
: 
 285        pstmt
->asyn_on 
= en_NumResultCols
; 
 306     UCHAR FAR 
* szColName
, 
 308     SWORD FAR 
* pcbColName
, 
 309     SWORD FAR 
* pfSqlType
, 
 310     UDWORD FAR 
* pcbColDef
, 
 311     SWORD FAR 
* pibScale
, 
 312     SWORD FAR 
* pfNullable
) 
 314   STMT_t FAR 
*pstmt 
= (STMT_t FAR 
*) hstmt
; 
 317   int sqlstat 
= en_00000
; 
 319   if (hstmt 
== SQL_NULL_HSTMT
 
 320       || pstmt
->hdbc 
== SQL_NULL_HDBC
) 
 322       return SQL_INVALID_HANDLE
; 
 325   /* check arguments */ 
 330   else if (cbColNameMax 
< 0) 
 335   if (sqlstat 
!= en_00000
) 
 337       PUSHSQLERR (pstmt
->herr
, sqlstat
); 
 343   if (pstmt
->asyn_on 
== en_NullProc
) 
 345       if (pstmt
->asyn_on 
== en_stmt_allocated
 
 346           || pstmt
->asyn_on 
>= en_stmt_needdata
) 
 351   else if (pstmt
->asyn_on 
!= en_DescribeCol
) 
 356   if (sqlstat 
!= en_00000
) 
 358       PUSHSQLERR (pstmt
->herr
, sqlstat
); 
 364   hproc 
= _iodbcdm_getproc (pstmt
->hdbc
, en_DescribeCol
); 
 366   if (hproc 
== SQL_NULL_HPROC
) 
 368       PUSHSQLERR (pstmt
->herr
, en_IM001
); 
 373   CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_DescribeCol
, 
 374     (pstmt
->dhstmt
, icol
, szColName
, cbColNameMax
, pcbColName
, 
 375       pfSqlType
, pcbColDef
, pibScale
, pfNullable
)) 
 377   /* state transition */ 
 378   if (pstmt
->asyn_on 
== en_DescribeCol
) 
 383          case SQL_SUCCESS_WITH_INFO
: 
 385            pstmt
->asyn_on 
= en_NullProc
; 
 393   switch (pstmt
->state
) 
 395      case en_stmt_prepared
: 
 396      case en_stmt_cursoropen
: 
 397      case en_stmt_fetched
: 
 398      case en_stmt_xfetched
: 
 399        if (retcode 
== SQL_STILL_EXECUTING
) 
 401            pstmt
->asyn_on 
= en_DescribeCol
; 
 423   STMT_t FAR 
*pstmt 
= (STMT_t FAR 
*) hstmt
; 
 426   int sqlstat 
= en_00000
; 
 428   if (hstmt 
== SQL_NULL_HSTMT 
|| pstmt
->hdbc 
== SQL_NULL_HDBC
) 
 430       return SQL_INVALID_HANDLE
; 
 433   /* check arguments */ 
 434   if (icol 
== 0 && fDescType 
!= SQL_COLUMN_COUNT
) 
 438   else if (cbDescMax 
< 0) 
 442   else if (                     /* fDescType < SQL_COLATT_OPT_MIN || *//* turnoff warning */ 
 443         (fDescType 
> SQL_COLATT_OPT_MAX
 
 444           && fDescType 
< SQL_COLUMN_DRIVER_START
)) 
 449   if (sqlstat 
!= en_00000
) 
 451       PUSHSQLERR (pstmt
->herr
, sqlstat
); 
 457   if (pstmt
->asyn_on 
== en_NullProc
) 
 459       if (pstmt
->asyn_on 
== en_stmt_allocated
 
 460           || pstmt
->asyn_on 
>= en_stmt_needdata
) 
 465   else if (pstmt
->asyn_on 
!= en_ColAttributes
) 
 470   if (sqlstat 
!= en_00000
) 
 472       PUSHSQLERR (pstmt
->herr
, sqlstat
); 
 478   hproc 
= _iodbcdm_getproc (pstmt
->hdbc
, en_ColAttributes
); 
 480   if (hproc 
== SQL_NULL_HPROC
) 
 482       PUSHSQLERR (pstmt
->herr
, en_IM001
); 
 487   CALL_DRIVER (pstmt
->hdbc
, retcode
, hproc
, en_ColAttributes
, 
 488     (pstmt
->dhstmt
, icol
, fDescType
, rgbDesc
, cbDescMax
, pcbDesc
, pfDesc
)) 
 490   /* state transition */ 
 491   if (pstmt
->asyn_on 
== en_ColAttributes
) 
 496          case SQL_SUCCESS_WITH_INFO
: 
 498            pstmt
->asyn_on 
= en_NullProc
; 
 506   switch (pstmt
->state
) 
 508      case en_stmt_prepared
: 
 509      case en_stmt_cursoropen
: 
 510      case en_stmt_fetched
: 
 511      case en_stmt_xfetched
: 
 512        if (retcode 
== SQL_STILL_EXECUTING
) 
 514            pstmt
->asyn_on 
= en_ColAttributes
;