|
| 1 | +# |
| 2 | +# Licensed Materials - Property of IBM |
| 3 | +# |
| 4 | +# (c) Copyright IBM Corp. 2007-2008 |
| 5 | +# |
| 6 | + |
| 7 | +from __future__ import print_function |
| 8 | +import sys |
| 9 | +import unittest |
| 10 | +import ibm_db |
| 11 | +import ibm_db_dbi |
| 12 | +import config |
| 13 | +from testfunctions import IbmDbTestFunctions |
| 14 | + |
| 15 | + |
| 16 | +class IbmDbTestCase(unittest.TestCase): |
| 17 | + |
| 18 | + def test_315_FetchAll_DBI(self): |
| 19 | + obj = IbmDbTestFunctions() |
| 20 | + obj.assert_expect(self.run_test_315) |
| 21 | + |
| 22 | + def run_test_315(self): |
| 23 | + conn = ibm_db.connect(config.database, config.user, config.password) |
| 24 | + |
| 25 | + ibm_db.autocommit(conn, ibm_db.SQL_AUTOCOMMIT_OFF) |
| 26 | + |
| 27 | + # Drop the test table, in case it exists |
| 28 | + drop = 'DROP TABLE varigraph' |
| 29 | + try: |
| 30 | + result = ibm_db.exec_immediate(conn, drop) |
| 31 | + except: |
| 32 | + pass |
| 33 | + |
| 34 | + # Create the test table |
| 35 | + create = 'CREATE TABLE varigraph( i INT, g VARGRAPHIC(10000))' |
| 36 | + result = ibm_db.exec_immediate(conn, create) |
| 37 | + |
| 38 | + vargraphic_string = "a" * 8192 |
| 39 | + |
| 40 | + insert_sql = "INSERT INTO varigraph (i, g) VALUES (?, ?)" |
| 41 | + stmt = ibm_db.prepare(conn, insert_sql) |
| 42 | + |
| 43 | + ibm_db.bind_param(stmt, 1, 0) |
| 44 | + ibm_db.bind_param(stmt, 2, 'hogehoge') |
| 45 | + ibm_db.execute(stmt) |
| 46 | + |
| 47 | + ibm_db.bind_param(stmt, 1, 1) |
| 48 | + ibm_db.bind_param(stmt, 2, vargraphic_string) |
| 49 | + ibm_db.execute(stmt) |
| 50 | + |
| 51 | + db2_conn = ibm_db_dbi.Connection(conn) |
| 52 | + db2_cur = db2_conn.cursor() |
| 53 | + |
| 54 | + sql = "SELECT i, length(g||g) FROM varigraph" |
| 55 | + |
| 56 | + try: |
| 57 | + db2_conn.cursor() |
| 58 | + db2_cur.execute(sql) |
| 59 | + for (i, len) in db2_cur.fetchall(): |
| 60 | + print("i: {} , len: {} ".format(i, len)) |
| 61 | + except: |
| 62 | + err = ibm_db.stmt_errormsg() |
| 63 | + print(err) |
| 64 | + |
| 65 | +#__END__ |
| 66 | +#__LUW_EXPECTED__ |
| 67 | +#[IBM][CLI Driver][DB2/LINUXX8664] SQL0137N The length resulting from "CONCAT" is greater than "0000016350 ". SQLSTATE=54006 SQLCODE=-137 |
| 68 | +#__ZOS_EXPECTED__ |
| 69 | +#[IBM][CLI Driver][DB2/LINUXX8664] SQL0137N The length resulting from "CONCAT" is greater than "0000016350 ". SQLSTATE=54006 SQLCODE=-137 |
| 70 | +#__SYSTEMI_EXPECTED__ |
| 71 | +#[IBM][CLI Driver][AS] SQL0137N The length resulting from "CONCAT" is greater than "0000016350 ". SQLSTATE=54006 SQLCODE=-137 |
| 72 | +#__IDS_EXPECTED__ |
| 73 | +#[IBM][CLI Driver][IDS/LINUXX8664] SQL0137N The length resulting from "CONCAT" is greater than "0000016350 ". SQLSTATE=54006 SQLCODE=-137 |
0 commit comments