+/*
+ * result.c
+ *
+ * $Id$
+ *
+ * Prepare for getting query result
+ *
+ * The iODBC driver manager.
+ *
+ * Copyright (C) 1995 by Ke Jin <kejin@empress.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "config.h"
+
+#include "isql.h"
+#include "isqlext.h"
+
+#include "dlproc.h"
+
+#include "herr.h"
+#include "henv.h"
+#include "hdbc.h"
+#include "hstmt.h"
+
+#include "itrace.h"
+
+RETCODE SQL_API
+SQLBindCol (
+ HSTMT hstmt,
+ UWORD icol,
+ SWORD fCType,
+ PTR rgbValue,
+ SDWORD cbValueMax,
+ SDWORD FAR * pcbValue)
+{
+ STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
+ HPROC hproc = SQL_NULL_HPROC;
+ RETCODE retcode;
+
+ if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
+ {
+ return SQL_INVALID_HANDLE;
+ }
+
+ /* check argument */
+ switch (fCType)
+ {
+ case SQL_C_DEFAULT:
+ case SQL_C_CHAR:
+ case SQL_C_BINARY:
+ case SQL_C_BIT:
+ case SQL_C_TINYINT:
+ case SQL_C_STINYINT:
+ case SQL_C_UTINYINT:
+ case SQL_C_SHORT:
+ case SQL_C_SSHORT:
+ case SQL_C_USHORT:
+ case SQL_C_LONG:
+ case SQL_C_SLONG:
+ case SQL_C_ULONG:
+ case SQL_C_FLOAT:
+ case SQL_C_DOUBLE:
+ case SQL_C_DATE:
+ case SQL_C_TIME:
+ case SQL_C_TIMESTAMP:
+ break;
+
+ default:
+ PUSHSQLERR (pstmt->herr, en_S1003);
+ return SQL_ERROR;
+ }
+
+ if (cbValueMax < 0)
+ {
+ PUSHSQLERR (pstmt->herr, en_S1090);
+
+ return SQL_ERROR;
+ }
+
+ /* check state */
+ if (pstmt->state > en_stmt_needdata || pstmt->asyn_on != en_NullProc)
+ {
+ PUSHSQLERR (pstmt->herr, en_S1010);
+ return SQL_ERROR;
+ }
+
+ /* call driver's function */
+ hproc = _iodbcdm_getproc (pstmt->hdbc, en_BindCol);
+
+ if (hproc == SQL_NULL_HPROC)
+ {
+ PUSHSQLERR (pstmt->herr, en_IM001);
+
+ return SQL_ERROR;
+ }
+
+ CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_BindCol,
+ (pstmt->dhstmt, icol, fCType, rgbValue, cbValueMax, pcbValue))
+
+ return retcode;
+}