-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathtest_stmt_get_sqlcode.py
More file actions
59 lines (53 loc) · 1.58 KB
/
test_stmt_get_sqlcode.py
File metadata and controls
59 lines (53 loc) · 1.58 KB
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
#
# 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_stmt_get_sqlcode(self):
obj = IbmDbTestFunctions()
obj.assert_expectf(self.run_test_stmt_get_sqlcode)
def run_test_stmt_get_sqlcode(self):
conn = ibm_db.connect(config.database, config.user, config.password)
if conn:
result = ''
result2 = ''
try:
result = ibm_db.exec_immediate(conn,"insert int0 t_string values(123,1.222333,'one to one')")
except:
pass
if result:
cols = ibm_db.num_fields(result)
print("col:", cols,", ")
rows = ibm_db.num_rows(result)
print("affected row:", rows)
else:
print(ibm_db.get_sqlcode())
try:
result = ibm_db.exec_immediate(conn,"delete from t_string where a=123")
except:
pass
if result:
cols = ibm_db.num_fields(result)
print("col:", cols,", ")
rows = ibm_db.num_rows(result)
print("affected row:", rows)
else:
print(ibm_db.get_sqlcode())
else:
print("no connection")
#__END__
#__LUW_EXPECTED__
#SQLCODE=-104
#__ZOS_EXPECTED__
#SQLCODE=-104
#__SYSTEMI_EXPECTED__
#SQLCODE=-104
#__IDS_EXPECTED__
#SQLCODE=-201