void tsc_fwd_ext_fetch (int ctype, int ac, char * text) { long count = 0; int rc = SQL_SUCCESS; long t1 = get_msec_count (); long last_row_no = 0; int do_testing = (strcmp(text, T1_BASE_TEXT) == 0); SQLSetConnectOption (hdbc1, SQL_AUTOCOMMIT, ac); t1_window (&tw1, "CR1", hdbc1, text, ctype, 0, 20, SQL_CONCUR_READ_ONLY, NULL); for (;;) { rc = SQLExtendedFetch (tw1.tw_stmt, SQL_FETCH_NEXT, 0, &tw1.tw_fill, tw1.tw_stat); if (rc == SQL_NO_DATA_FOUND || rc == SQL_ERROR) break; if (do_testing) { if (count && tw1.tw_set[0].t1_row_no <= last_row_no) fprintf (stderr, "*** Error : Overlapping rowsets in SQL_FETCH_NEXT : mode = %s\n", cr_type_name (ctype)); last_row_no = tw1.tw_set[tw1.tw_fill - 1].t1_row_no; } count += tw1.tw_fill; } if (SQL_ERROR == rc) print_error (SQL_NULL_HENV, SQL_NULL_HDBC, tw1.tw_stmt); tw_close (&tw1); printf ("SQLExtendedFetch: %ld msec, mode = %s, AC=%d, %ld row\n", get_msec_count () - t1, cr_type_name (ctype), ac, count); }
void tsc_co (int ctype, int kssz, int ac) { int rc; char * text = "select ROW_NO, STRING1, STRING2, FS1, FI2 from T1 where ROW_NO >= 3000"; printf ("\n========== WHERE CURRENT OF Test, type = %d, AC=%d\n", ctype, ac); SQLSetConnectOption (hdbc1, SQL_AUTOCOMMIT, ac); t1_lines (&tw1, 3000, 4000, 5); t1_window (&tw1, "CR1", hdbc1, text, SQL_CURSOR_DYNAMIC, kssz, 5, SQL_CONCUR_READ_ONLY, NULL); tw_fetch (&tw1, SQL_FETCH_NEXT, 0); tw_set_pos (&tw1, 3, SQL_POSITION); tw_exec (&tw1, "update T1 set FS1 = 'UUU' where current of CR1"); tw_set_pos (&tw1, 3, SQL_REFRESH); T_CCOL (&tw1, 2, t1_fs1, "UUU"); tw_exec (&tw1, "delete from T1 where current of CR1"); tw_set_pos (&tw1, 3, SQL_REFRESH); T_RSTAT (&tw1, 2, SQL_ROW_DELETED); ERRORS_OFF; tw_exec (&tw1, "delete from T1 where current of CR1"); ERRORS_ON; T_RC (&tw1, SQL_ERROR); tw_close (&tw1); t1_window (&tw1, "CR1", hdbc1, text, ctype, 0, 5, SQL_CONCUR_READ_ONLY, NULL); QUIET; for (;;) { rc = SQLExtendedFetch (tw1.tw_stmt, SQL_FETCH_NEXT, 0, &tw1.tw_fill, tw1.tw_stat); if (SQL_NO_DATA_FOUND == rc) break; IF_ERR_GO (tw1.tw_stmt, err, rc); tw_set_pos (&tw1, 1, SQL_POSITION); tw_exec (&tw1, "delete from T1 where current of CR1"); if (tw1.tw_fill < 5) { ERRORS_OFF; tw_set_pos (&tw1, 5, SQL_POSITION); T_RC (&tw1, SQL_ERROR); tw_exec (&tw1, "delete from T1 where current of CR1"); ERRORS_ON; } else { tw_set_pos (&tw1, 5, SQL_POSITION); tw_exec (&tw1, "delete from T1 where current of CR1"); } } err: QUIET_OFF; tw_exec (&tw1, "delete from T1 where ROW_NO >= 3000"); T_ROWCNT (&tw1, 600); /* 1000 rows - 1+199*2+1 deletes */ if (!ac) SQLTransact (SQL_NULL_HENV, tw1.tw_hdbc, SQL_ROLLBACK); tw_close (&tw1); }
void tw_fetch (t1_window_t * tw, int ftype, int n) { int rc; tw_unset (tw); /* rc = SQLExtendedFetch (tw->tw_stmt, ftype, n, &tw->tw_fill, tw->tw_stat); */ rc = SQLExtendedFetch (tw->tw_stmt, ftype, n, &tw->tw_fill, tw->tw_stat); tw->tw_rc = rc; printf ("\nFetch %s %d %d = %d\n", tw->tw_name, ftype, n, rc); IF_ERR_GO (tw->tw_stmt, err, rc); tw_print (tw); err: ; }
void tsc_commit_cursor (t1_window_t * tw, int ctype, int commit) { long count = 0; int rc = SQL_SUCCESS; long last_row_no = 0; printf ("STARTED: %s on open autocommit %s cursor\n", commit == SQL_COMMIT ? "commit" : "rollback", cr_type_name (ctype)); SQLSetConnectOption (tw->tw_hdbc, SQL_AUTOCOMMIT, 1); t1_window (tw, "CR1", tw->tw_hdbc, T1_BASE_TEXT, ctype, 0, 20, SQL_CONCUR_READ_ONLY, NULL); for (count = 0; count < tw->tw_fill * 2; count += tw->tw_fill) { rc = SQLExtendedFetch (tw->tw_stmt, SQL_FETCH_NEXT, 0, &tw->tw_fill, tw->tw_stat); if (rc == SQL_NO_DATA_FOUND || rc == SQL_ERROR) break; if (count && tw->tw_set[0].t1_row_no <= last_row_no) fprintf (stderr, "*** Error : Overlapping rowsets in SQL_FETCH_NEXT : mode = %s\n", cr_type_name (ctype)); last_row_no = tw->tw_set[tw->tw_fill - 1].t1_row_no; if (!count) { printf ("SQLTransact (%s) on open autocommit %s cursor\n", commit == SQL_COMMIT ? "commit" : "rollback", cr_type_name (ctype)); rc = SQLTransact (SQL_NULL_HENV, tw->tw_hdbc, commit); if (rc == SQL_ERROR) break; } } if (SQL_ERROR == rc) print_error (SQL_NULL_HENV, SQL_NULL_HDBC, tw->tw_stmt); tw_close (tw); printf ("DONE: %s on open autocommit %s cursor\n\n", commit == SQL_COMMIT ? "commit" : "rollback", cr_type_name (ctype)); }
static int odbc_dispatch10(void) { unsigned long retval; PWord rval; int rtype; PWord arg1; int type1; PWord arg2; int type2; PWord arg3; int type3; PWord arg4; int type4; PWord arg5; int type5; PWord arg6; int type6; PWord arg7; int type7; PI_getan(&arg1,&type1,1); if (type1 != PI_INT) if (!CI_get_integer((unsigned long *)&arg1,type1)) PI_FAIL; PI_getan(&arg2,&type2,2); if (type2 != PI_INT) if (!CI_get_integer((unsigned long *)&arg2,type2)) PI_FAIL; PI_getan(&arg3,&type3,3); if (type3 != PI_INT) if (!CI_get_integer((unsigned long *)&arg3,type3)) PI_FAIL; PI_getan(&arg4,&type4,4); if (type4 != PI_INT) if (!CI_get_integer((unsigned long *)&arg4,type4)) PI_FAIL; PI_getan(&arg5,&type5,5); if (type5 != PI_INT) if (!CI_get_integer((unsigned long *)&arg5,type5)) PI_FAIL; PI_getan(&arg6,&type6,6); if (type6 != PI_INT) if (!CI_get_integer((unsigned long *)&arg6,type6)) PI_FAIL; PI_getan(&arg7,&type7,7); switch(arg1) { case 0: retval = (unsigned long) SQLExtendedFetch(((SQLHSTMT ) arg2),((SQLUSMALLINT ) arg3),((SQLINTEGER ) arg4),((SQLUINTEGER * ) arg5),((SQLUSMALLINT * ) arg6)); break; case 1: retval = (unsigned long) SQLSetDescField(((SQLHDESC ) arg2),((SQLSMALLINT ) arg3),((SQLSMALLINT ) arg4),((SQLPOINTER ) arg5),((SQLINTEGER ) arg6)); break; case 2: retval = (unsigned long) SQLGetStmtAttr(((SQLHSTMT ) arg2),((SQLINTEGER ) arg3),((SQLPOINTER ) arg4),((SQLINTEGER ) arg5),((SQLINTEGER * ) arg6)); break; case 3: retval = (unsigned long) SQLGetInfo(((SQLHDBC ) arg2),((SQLUSMALLINT ) arg3),((SQLPOINTER ) arg4),((SQLSMALLINT ) arg5),((SQLSMALLINT * ) arg6)); break; case 4: retval = (unsigned long) SQLGetEnvAttr(((SQLHENV ) arg2),((SQLINTEGER ) arg3),((SQLPOINTER ) arg4),((SQLINTEGER ) arg5),((SQLINTEGER * ) arg6)); break; case 5: retval = (unsigned long) SQLGetConnectAttr(((SQLHDBC ) arg2),((SQLINTEGER ) arg3),((SQLPOINTER ) arg4),((SQLINTEGER ) arg5),((SQLINTEGER * ) arg6)); break; default: PI_FAIL; } PI_makedouble(&rval,&rtype,(double) retval); if (PI_unify(arg7,type7,rval,rtype)) PI_SUCCEED; PI_FAIL; }