Line data Source code
1 : /* 2 : * SPDX-License-Identifier: MPL-2.0 3 : * 4 : * This Source Code Form is subject to the terms of the Mozilla Public 5 : * License, v. 2.0. If a copy of the MPL was not distributed with this 6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 : * 8 : * Copyright 2024 MonetDB Foundation; 9 : * Copyright August 2008 - 2023 MonetDB B.V.; 10 : * Copyright 1997 - July 2008 CWI. 11 : */ 12 : 13 : /* 14 : * This code was created by Peter Harvey (mostly during Christmas 98/99). 15 : * This code is LGPL. Please ensure that this message remains in future 16 : * distributions and uses of this code (thats about all I get out of it). 17 : * - Peter Harvey pharvey@codebydesign.com 18 : * 19 : * This file has been modified for the MonetDB project. See the file 20 : * Copyright in this directory for more information. 21 : */ 22 : 23 : /********************************************************************** 24 : * SQLRowCount() 25 : * CLI Compliance: ISO 92 26 : * 27 : * Author: Martin van Dinther, Sjoerd Mullender 28 : * Date : 30 aug 2002 29 : * 30 : **********************************************************************/ 31 : 32 : #include "ODBCGlobal.h" 33 : #include "ODBCStmt.h" 34 : 35 : 36 : SQLRETURN SQL_API 37 : SQLRowCount(SQLHSTMT StatementHandle, 38 : SQLLEN *RowCountPtr) 39 : { 40 86 : ODBCStmt *stmt = (ODBCStmt *) StatementHandle; 41 : 42 : #ifdef ODBCDEBUG 43 86 : ODBCLOG("SQLRowCount %p\n", StatementHandle); 44 : #endif 45 : 46 86 : if (!isValidStmt(stmt)) 47 : return SQL_INVALID_HANDLE; 48 : 49 86 : clearStmtErrors(stmt); 50 : 51 : /* check statement cursor state, query should be executed */ 52 86 : if (stmt->State < EXECUTED0) { 53 : /* Function sequence error */ 54 0 : addStmtError(stmt, "HY010", NULL, 0); 55 0 : return SQL_ERROR; 56 : } 57 : 58 : /* check output parameter */ 59 86 : if (RowCountPtr == NULL) { 60 : /* Invalid use of null pointer */ 61 0 : addStmtError(stmt, "HY009", NULL, 0); 62 0 : return SQL_ERROR; 63 : } 64 : 65 : /* We can now set the "number of result set rows" value */ 66 86 : *RowCountPtr = (SQLLEN) stmt->rowcount; 67 : 68 86 : return SQL_SUCCESS; 69 : }