LCOV - code coverage report
Current view: top level - src/odbc/unittests - prepare_warn.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 24 24 100.0 %
Date: 2025-01-18 11:50:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Author           : sf@4js.com
       3             :  * FreeTDS version  : 0.91RC2 (20110429)
       4             :  * Platform         : Linux 32b (Debian Lenny)
       5             :  * Fetching when there is a NULL value in table gives invalid cursor state error.
       6             :  * Is this because of Warning SQLSTATE 01003?
       7             :  */
       8             : 
       9             : #include "common.h"
      10             : 
      11             : int
      12           8 : main(void)
      13             : {
      14             : #define ARRAY_SIZE 10
      15             :         SQLCHAR v_dec[ARRAY_SIZE][21];
      16             :         SQLLEN v_ind[ARRAY_SIZE];
      17             :         SQLULEN nrows;
      18             : 
      19           8 :         odbc_use_version3 = 1;
      20           8 :         odbc_connect();
      21           8 :         odbc_check_cursor();
      22             : 
      23           6 :         odbc_command("IF OBJECT_ID('mytab1') IS NOT NULL DROP TABLE mytab1");
      24           6 :         odbc_command("CREATE TABLE mytab1 ( k INT, d DECIMAL(10,2))");
      25           6 :         odbc_command("INSERT INTO mytab1 VALUES ( 201, 111.11 )");
      26             :         /*SQLExecDirect(m_hstmt, (SQLCHAR *) "insert into mytab1 values ( 202, 222.22 )", SQL_NTS); */
      27           6 :         odbc_command("INSERT INTO mytab1 VALUES ( 202, null )");
      28             : 
      29           6 :         odbc_reset_statement();
      30             : 
      31           6 :         CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S");
      32           6 :         CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S");
      33             : 
      34           6 :         CHKSetStmtAttr(SQL_ATTR_ROW_BIND_TYPE, (SQLPOINTER) SQL_BIND_BY_COLUMN, SQL_IS_UINTEGER, "S");
      35           6 :         CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) ARRAY_SIZE, SQL_IS_UINTEGER, "S");
      36           6 :         CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, (SQLPOINTER) & (nrows), SQL_IS_UINTEGER, "S");
      37             : 
      38           6 :         CHKPrepare(T("SELECT SUM(d) FROM mytab1"), SQL_NTS, "S");
      39             : 
      40           6 :         CHKExecute("I");
      41             : 
      42             : #if 0
      43             :         CHKMoreResults("S");  /* skip warning*/
      44             : #endif
      45             : 
      46           6 :         CHKBindCol(1, SQL_C_CHAR, v_dec, 21, v_ind, "S");
      47             : 
      48           6 :         CHKFetch("S");
      49             : 
      50           6 :         printf("fetch 1: rows fetched = %d\n", (int) nrows);
      51           6 :         printf("fetch 1: value = [%s]\n", v_dec[0]);
      52             : 
      53           6 :         CHKFetch("No");
      54             : 
      55           6 :         CHKMoreResults("No");
      56             : 
      57           6 :         odbc_command("drop table mytab1");
      58             : 
      59           6 :         odbc_disconnect();
      60             : 
      61             :         return 0;
      62             : }
      63             : 

Generated by: LCOV version 1.13