-
Notifications
You must be signed in to change notification settings - Fork 195
/
test_017_selectRowcountPrefetchSTMTOpt.py
90 lines (83 loc) · 3.01 KB
/
test_017_selectRowcountPrefetchSTMTOpt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#
# Licensed Materials - Property of IBM
#
# (c) Copyright IBM Corp. 2007-2008
#
from __future__ import print_function
import sys
import unittest
import ibm_db
import config
from testfunctions import IbmDbTestFunctions
class IbmDbTestCase(unittest.TestCase):
def test_017_selectRowcountPrefetchSTMTOpt(self):
obj = IbmDbTestFunctions()
obj.assert_expect(self.run_test_017)
def run_test_017(self):
conn = ibm_db.connect(config.database, config.user, config.password)
if conn:
if ('zos' in sys.platform):
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0")
else:
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0", { ibm_db.SQL_ATTR_CURSOR_TYPE : ibm_db.SQL_CURSOR_KEYSET_DRIVEN})
if result:
rows = ibm_db.num_rows(result)
print("affected row:", rows)
else:
print(ibm_db.stmt_errormsg())
if('zos' in sys.platform):
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0")
else:
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0", {ibm_db.SQL_ATTR_CURSOR_TYPE : ibm_db.SQL_CURSOR_FORWARD_ONLY})
if result:
rows = ibm_db.num_rows(result)
print("affected row:", rows)
else:
print(ibm_db.stmt_errormsg())
if ('zos' in sys.platform):
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0")
else:
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0", {ibm_db.SQL_ATTR_ROWCOUNT_PREFETCH : ibm_db.SQL_ROWCOUNT_PREFETCH_ON})
if result:
rows = ibm_db.num_rows(result)
print("affected row:", rows)
else:
print(ibm_db.stmt_errormsg())
if('zos' in sys.platform):
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0")
else:
result = ibm_db.exec_immediate(conn,"SELECT * from animals WHERE weight < 10.0", {ibm_db.SQL_ATTR_ROWCOUNT_PREFETCH : ibm_db.SQL_ROWCOUNT_PREFETCH_OFF})
if result:
rows = ibm_db.num_rows(result)
print("affected row:", rows)
else:
print(ibm_db.stmt_errormsg())
ibm_db.close(conn)
else:
print("no connection:", ibm_db.conn_errormsg())
#__END__
#__LUW_EXPECTED__
#affected row: 4
#affected row: -1
#affected row: 4
#affected row: -1
#__ZOS_EXPECTED__
#affected row: 4
#affected row: -1
#affected row: 4
#affected row: -1
#__SYSTEMI_EXPECTED__
#affected row: 4
#affected row: -1
#affected row: 4
#affected row: -1
#__IDS_EXPECTED__
#affected row: 4
#affected row: -1
#affected row: 4
#affected row: -1
#__ZOS_ODBC_EXPECTED__
#affected row: -1
#affected row: -1
#affected row: -1
#affected row: -1