def run_test_150(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select * from staff") row = ifx_db.fetch_assoc(result) while (row): #print "%5d " % row['ID'] #print "%-10s " % row['NAME'] #print "%5d " % row['DEPT'] #print "%-7s " % row['JOB'] #print "%5d " % row['YEARS'] #print "%15s " % row['SALARY'] #print "%10s " % row['COMM'] if (row['YEARS'] == None): row['YEARS'] = 0 if (row['COMM'] == None): row['COMM'] = '' print "%5d %-10s %5d %-7s %5s %15s %10s " % ( row['ID'], row['NAME'], row['DEPT'], row['JOB'], row['YEARS'], row['SALARY'], row['COMM']) row = ifx_db.fetch_assoc(result)
def run_test_158(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info( conn ) if (server.DBMS_NAME[0:3] == 'Inf'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "SELECT * FROM staff WHERE id < 50") output = '' row = ifx_db.fetch_assoc(result) while ( row ): output += str(row['ID']) + ', ' + row['NAME'] + ', ' + str(row['DEPT']) + ', ' + row['JOB'] + ', ' + str(row['YEARS']) + ', ' + str(row['SALARY']) + ', ' + str(row['COMM']) row = ifx_db.fetch_assoc(result) result2 = ifx_db.exec_immediate(conn,"SELECT * FROM department WHERE substr(deptno,1,1) in ('A','B','C','D','E')") row2 = ifx_db.fetch_assoc(result2) while ( row2 ): if (row2['MGRNO'] == None): row2['MGRNO'] = '' if (row2['LOCATION'] == None): row2['LOCATION'] = '' output += str(row2['DEPTNO']) + ', ' + row2['DEPTNAME'] + ', ' + str(row2['MGRNO']) + ', ' + row2['ADMRDEPT'] + ', ' + row2['LOCATION'] row2 = ifx_db.fetch_assoc(result2) result3 = ifx_db.exec_immediate(conn,"SELECT * FROM employee WHERE lastname IN ('HAAS','THOMPSON', 'KWAN', 'GEYER', 'STERN', 'PULASKI', 'HENDERSON', 'SPENSER', 'LUCCHESSI', 'OCONNELL', 'QUINTANA', 'NICHOLLS', 'ADAMSON', 'PIANKA', 'YOSHIMURA', 'SCOUTTEN', 'WALKER', 'BROWN', 'JONES', 'LUTZ', 'JEFFERSON', 'MARINO', 'SMITH', 'JOHNSON', 'PEREZ', 'SCHNEIDER', 'PARKER', 'SMITH', 'SETRIGHT', 'MEHTA', 'LEE', 'GOUNOT')") row3 = ifx_db.fetch_tuple(result3) while ( row3 ): output += row3[0] + ', ' + row3[3] + ', ' + row3[5] row3=ifx_db.fetch_tuple(result3) print output
def run_test_157(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if conn: sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed" if (server.DBMS_NAME[0:3] != 'IDS'): result = ifx_db.exec_immediate(conn, sql, { ifx_db.SQL_ATTR_CURSOR_TYPE: ifx_db.SQL_CURSOR_KEYSET_DRIVEN }) else: result = ifx_db.exec_immediate( conn, sql, {ifx_db.SQL_ATTR_CURSOR_TYPE: ifx_db.SQL_CURSOR_STATIC}) i = 2 row = ifx_db.fetch_assoc(result, i) while (row): if (server.DBMS_NAME[0:3] == 'IDS'): print "%-5d %-16s %-32s %10s\n" % ( row['id'], row['name'], row['breed'], row['weight']) else: print "%-5d %-16s %-32s %10s\n" % ( row['ID'], row['NAME'], row['BREED'], row['WEIGHT']) i = i + 2 row = ifx_db.fetch_assoc(result, i)
def run_test_152(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'Inf'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select * from project") row = ifx_db.fetch_assoc(result) while (row): #printf("%6s ",row['PROJNO']) #printf("%-24s ",row['PROJNAME']) #printf("%3s ",row['DEPTNO']) #printf("%6s",row['RESPEMP']) #printf("%7s ",row['PRSTAFF']) #printf("%10s ",row['PRSTDATE']) #printf("%10s ",row['PRENDATE']) #printf("%6s",row['MAJPROJ']) #puts "" if (row['MAJPROJ'] == None): row['MAJPROJ'] = '' print "%6s %-24s %3s %6s%7s %10s %10s %6s" % ( row['PROJNO'], row['PROJNAME'], row['DEPTNO'], row['RESPEMP'], row['PRSTAFF'], row['PRSTDATE'], row['PRENDATE'], row['MAJPROJ']) row = ifx_db.fetch_assoc(result)
def run_test_157a(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) print "Starting..." if conn: sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed" result = ifx_db.exec_immediate(conn, sql) try: i = 2 row = ifx_db.fetch_assoc(result, i) while (row): if (server.DBMS_NAME[0:3] == 'IDS'): print "%-5d %-16s %-32s %10s" % ( row['id'], row['name'], row['breed'], row['weight']) else: print "%-5d %-16s %-32s %10s" % ( row['ID'], row['NAME'], row['BREED'], row['WEIGHT']) i = i + 2 row = ifx_db.fetch_assoc(result, i) except: print "SQLSTATE: %s" % ifx_db.stmt_error(result) print "Message: %s" % ifx_db.stmt_errormsg(result) print "DONE"
def run_test_155(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) serverinfo = ifx_db.server_info(conn) result = ifx_db.exec_immediate( conn, "select * from employee where lastname in ('HAAS','THOMPSON', 'KWAN', 'GEYER', 'STERN', 'PULASKI', 'HENDERSON', 'SPENSER', 'LUCCHESSI', 'OCONNELL', 'QUINTANA', 'NICHOLLS', 'ADAMSON', 'PIANKA', 'YOSHIMURA', 'SCOUTTEN', 'WALKER', 'BROWN', 'JONES', 'LUTZ', 'JEFFERSON', 'MARINO', 'SMITH', 'JOHNSON', 'PEREZ', 'SCHNEIDER', 'PARKER', 'SMITH', 'SETRIGHT', 'MEHTA', 'LEE', 'GOUNOT')" ) i = 0 row = ifx_db.fetch_assoc(result) while (row): i += 1 if (serverinfo.DBMS_NAME[0:3] == 'IDS'): if (row['midinit'] == None): row['midinit'] = '' print "%6s %12s %s %-15s%3s %4s %10s %-8s%4d %s%10s %12s %12s %12s" % \ (row['empno'], row['firstnme'], row['midinit'], row['lastname'], row['workdept'], \ row['phoneno'], row['hiredate'], row['job'], row['edlevel'], row['sex'], \ row['birthdate'], row['salary'], row['bonus'], row['comm']) row = ifx_db.fetch_assoc(result) else: if (row['MIDINIT'] == None): row['MIDINIT'] = '' print "%6s %12s %s %-15s%3s %4s %10s %-8s%4d %s%10s %12s %12s %12s" % \ (row['EMPNO'], row['FIRSTNME'], row['MIDINIT'], row['LASTNAME'], row['WORKDEPT'], \ row['PHONENO'], row['HIREDATE'], row['JOB'], row['EDLEVEL'], row['SEX'], \ row['BIRTHDATE'], row['SALARY'], row['BONUS'], row['COMM']) row = ifx_db.fetch_assoc(result) print "%d record(s) selected." % i
def run_test_133(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) if (not conn): print "Connection failed." return 0 ifx_db.autocommit(conn, ifx_db.SQL_AUTOCOMMIT_OFF) print "Starting test ..." res = '' sql = "INSERT INTO animals (id, breed, name, weight) VALUES (?, ?, ?, ?)" try: stmt = ifx_db.prepare(conn, sql) res = ifx_db.execute( stmt, (128, 'hacker of human and technological nature', 'Wez the ruler of all things PECL', 88.3)) stmt = ifx_db.prepare( conn, "SELECT breed, name FROM animals WHERE id = ?") res = ifx_db.execute(stmt, (128, )) row = ifx_db.fetch_assoc(stmt) for i in row: print i ifx_db.rollback(conn) print "Done" except: print "SQLSTATE: %s" % ifx_db.stmt_error(stmt) print "Message: %s" % ifx_db.stmt_errormsg(stmt) try: stmt = ifx_db.prepare( conn, "SELECT breed, name FROM animals WHERE id = ?") res = ifx_db.execute(stmt, (128, )) row = ifx_db.fetch_assoc(stmt) if (row): for i in row: print i print res print "SQLSTATE: %s" % ifx_db.stmt_error(stmt) print "Message: %s" % ifx_db.stmt_errormsg(stmt) except: print "An Exception is not expected" print "SQLSTATE: %s" % ifx_db.stmt_error(stmt) print "Message: %s" % ifx_db.stmt_errormsg(stmt) ifx_db.rollback(conn) print "Done"
def run_test_159(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info( conn ) if (server.DBMS_NAME[0:3] == 'IDS'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select name,job from staff") i = 1 row = ifx_db.fetch_assoc(result) while ( row ): #printf("%3d %10s %10s\n",i, row['NAME'], row['JOB']) print "%3d %10s %10s" % (i, row['NAME'], row['JOB']) i += 1 row = ifx_db.fetch_assoc(result)
def run_test_159a(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate( conn, "select prstdate,prendate from project") i = 1 row = ifx_db.fetch_assoc(result) while (row): #printf("%3d %10s %10s\n",i, row['PRSTDATE'], row['PRENDATE']) print "%3d %10s %10s" % (i, row['PRSTDATE'], row['PRENDATE']) i += 1 row = ifx_db.fetch_assoc(result)
def run_test_151(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info( conn ) if (server.DBMS_NAME[0:3] == 'Inf'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select * from sales") row = ifx_db.fetch_assoc(result) while ( row ): #printf("%-10s ",row['SALES_DATE']) #printf("%-15s ",row['SALES_PERSON']) #printf("%-15s ",row['REGION']) #printf("%4s",row['SALES']) #puts "" if (row['SALES'] == None): row['SALES'] = '' print "%-10s %-15s %-15s %4s" % (row['SALES_DATE'], row['SALES_PERSON'], row['REGION'], row['SALES']) row = ifx_db.fetch_assoc(result)
def run_test_261(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'Inf'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) if (server.DBMS_NAME[0:3] == 'Inf'): sql = "SELECT breed, TRIM(TRAILING FROM name) AS name FROM animals WHERE id = ?" else: sql = "SELECT breed, RTRIM(name) AS name FROM animals WHERE id = ?" if conn: stmt = ifx_db.prepare(conn, sql) ifx_db.execute(stmt, (0, )) # NOTE: This is a workaround # function fetch_object() to be implemented... # pet = ifx_db.fetch_object(stmt) # while (pet): # print "Come here, %s, my little %s!" % (pet.NAME, pet.BREED) # pet = ifx_db.fetch_object(stmt) class Pet: pass data = ifx_db.fetch_assoc(stmt) while (data): pet = Pet() pet.NAME = data['NAME'] pet.BREED = data['BREED'] print "Come here, %s, my little %s!" % (pet.NAME, pet.BREED) data = ifx_db.fetch_assoc(stmt) ifx_db.close(conn) else: print "Connection failed."
def run_test_157b(self): conn = ifx_db.connect(config.ConnStr + 'ENABLESCROLLABLECURSORS=1', config.user, config.password) server = ifx_db.server_info( conn ) if conn: sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed" if (server.DBMS_NAME[0:3] != 'Inf'): stmt = ifx_db.prepare(conn, sql, {ifx_db.SQL_ATTR_CURSOR_TYPE: ifx_db.SQL_CURSOR_KEYSET_DRIVEN}) else: stmt = ifx_db.prepare(conn, sql, {ifx_db.SQL_ATTR_CURSOR_TYPE: ifx_db.SQL_CURSOR_STATIC}) result = ifx_db.execute(stmt) i = 2 row = ifx_db.fetch_assoc(stmt, i) while ( row ): if (server.DBMS_NAME[0:3] == 'Inf'): #printf("%-5d %-16s %-32s %10s\n", row['id'], row['name'], row['breed'], row['weight']) print "%-5d %-16s %-32s %10s" % (row['id'], row['name'], row['breed'], row['weight']) else: #printf("%-5d %-16s %-32s %10s\n", row['ID'], row['NAME'], row['BREED'], row['WEIGHT']) print "%-5d %-16s %-32s %10s" % (row['ID'], row['NAME'], row['BREED'], row['WEIGHT']) i = i + 2 row = ifx_db.fetch_assoc(stmt, i)
def run_test_153(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'Inf'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select * from org") row = ifx_db.fetch_assoc(result) while (row): #printf("%4d ",row['DEPTNUMB']) #printf("%-14s ",row['DEPTNAME']) #printf("%4d ",row['MANAGER']) #printf("%-10s",row['DIVISION']) #printf("%-13s ",row['LOCATION']) #puts "" print "%4d %-14s %4d %-10s%-13s " % ( row['DEPTNUMB'], row['DEPTNAME'], row['MANAGER'], row['DIVISION'], row['LOCATION']) row = ifx_db.fetch_assoc(result)
def run_test_034(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select * from staff") row = ifx_db.fetch_assoc(result) if (row): #printf("%5d ",row['ID']) #printf("%-10s ",row['NAME']) #printf("%5d ",row['DEPT']) #printf("%-7s ",row['JOB']) #printf("%5d ", row['YEARS']) #printf("%15s ", row['SALARY']) #printf("%10s ", row['COMM']) #puts "" print "%5d %-10s %5d %-7s %5d %15s %10s" % ( row['ID'], row['NAME'], row['DEPT'], row['JOB'], row['YEARS'], row['SALARY'], row['COMM']) ifx_db.close(conn)
def run_test_133(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) if (not conn): print "Connection failed." return 0 ifx_db.autocommit(conn, ifx_db.SQL_AUTOCOMMIT_OFF) print "Starting test ..." res = '' sql = "INSERT INTO animals (id, breed, name, weight) VALUES (?, ?, ?, ?)" try: stmt = ifx_db.prepare(conn, sql) res = ifx_db.execute( stmt, (128, 'hacker of human and technological nature', 'Wez the ruler of all things PECL', 88.3)) stmt = ifx_db.prepare( conn, "SELECT breed, name FROM animals WHERE id = ?") res = ifx_db.execute(stmt, (128, )) row = ifx_db.fetch_assoc(stmt) for i in row: print i ifx_db.rollback(conn) print "Done" except: print "SQLSTATE: %s" % ifx_db.stmt_error(stmt) print "Message: %s" % ifx_db.stmt_errormsg(stmt) try: stmt = ifx_db.prepare( conn, "SELECT breed, name FROM animals WHERE id = ?") res = ifx_db.execute(stmt, (128, )) row = ifx_db.fetch_assoc(stmt) if (row): for i in row: print i print res print "SQLSTATE: %s" % ifx_db.stmt_error(stmt) print "Message: %s" % ifx_db.stmt_errormsg(stmt) except: print "An Exception is not expected" print "SQLSTATE: %s" % ifx_db.stmt_error(stmt) print "Message: %s" % ifx_db.stmt_errormsg(stmt) ifx_db.rollback(conn) print "Done" #__END__ #__LUW_EXPECTED__ #Starting test ... # #SQLSTATE: 22001 #Message: [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001 SQLCODE=-99999 #True #SQLSTATE: 02000 #Message: [IBM][CLI Driver][DB2/%s] SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000 SQLCODE=100 #Done #__ZOS_EXPECTED__ #Starting test ... # #SQLSTATE: 22001 #Message: [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001 SQLCODE=-99999 #True #SQLSTATE: 02000 #Message: [IBM][CLI Driver][DB2] SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000 SQLCODE=100 #Done #__SYSTEMI_EXPECTED__ #Starting test ... # #SQLSTATE: 22001 #Message: [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001 SQLCODE=-99999 #True #SQLSTATE: 02000 #Message: [IBM][CLI Driver][AS] SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000 SQLCODE=100 #Done #__IDS_EXPECTED__ #Starting test ... # #SQLSTATE: 22001 #Message: [IBM][CLI Driver][IDS%s] Value exceeds string column length. SQLCODE=-1279 #True #SQLSTATE: 02000 #Message: [IBM][CLI Driver][IDS%s] SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000 SQLCODE=100 #Done
def run_test_154(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) try: statement = 'DROP TABLE fetch_test' result = ifx_db.exec_immediate(conn, statement) except: pass server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): statement = 'CREATE TABLE fetch_test (col1 VARCHAR(20), col2 CLOB, col3 INTEGER)' st0 = "INSERT INTO fetch_test VALUES ('column 0', 'Data in the clob 0', 0)" st1 = "INSERT INTO fetch_test VALUES ('column 1', 'Data in the clob 1', 1)" st2 = "INSERT INTO fetch_test VALUES ('column 2', 'Data in the clob 2', 2)" st3 = "INSERT INTO fetch_test VALUES ('column 3', 'Data in the clob 3', 3)" else: statement = 'CREATE TABLE fetch_test (col1 VARCHAR(20), col2 CLOB(20), col3 INTEGER)' st0 = "INSERT INTO fetch_test VALUES ('column 0', 'Data in the clob 0', 0)" st1 = "INSERT INTO fetch_test VALUES ('column 1', 'Data in the clob 1', 1)" st2 = "INSERT INTO fetch_test VALUES ('column 2', 'Data in the clob 2', 2)" st3 = "INSERT INTO fetch_test VALUES ('column 3', 'Data in the clob 3', 3)" result = ifx_db.exec_immediate(conn, statement) result = ifx_db.exec_immediate(conn, st0) result = ifx_db.exec_immediate(conn, st1) result = ifx_db.exec_immediate(conn, st2) result = ifx_db.exec_immediate(conn, st3) statement = "SELECT col1, col2 FROM fetch_test" result = ifx_db.prepare(conn, statement) ifx_db.execute(result) row = ifx_db.fetch_tuple(result) while (row): #printf("\"%s\" from VARCHAR is %d bytes long, \"%s\" from CLOB is %d bytes long.\n", # row[0],row[0].length, row[1],row[1].length) print "\"%s\" from VARCHAR is %d bytes long, \"%s\" from CLOB is %d bytes long." %\ (row[0], len(row[0]), row[1], len(row[1])) row = ifx_db.fetch_tuple(result) result = ifx_db.prepare(conn, statement) ifx_db.execute(result) row = ifx_db.fetch_assoc(result) while (row): #printf("\"%s\" from VARCHAR is %d bytes long, \"%s\" from CLOB is %d bytes long.\n", # row['COL1'], row['COL1'].length, row['COL2'], row['COL2'].length) print "\"%s\" from VARCHAR is %d bytes long, \"%s\" from CLOB is %d bytes long." %\ (row['COL1'], len(row['COL1']), row['COL2'], len(row['COL2'])) row = ifx_db.fetch_assoc(result) result = ifx_db.prepare(conn, statement) ifx_db.execute(result) row = ifx_db.fetch_both(result) while (row): #printf("\"%s\" from VARCHAR is %d bytes long, \"%s\" from CLOB is %d bytes long.\n", # row['COL1'], row['COL1'].length, row[1], row[1].length) print "\"%s\" from VARCHAR is %d bytes long, \"%s\" from CLOB is %d bytes long.\n" % \ (row['COL1'],len(row['COL1']), row[1], len(row[1])) row = ifx_db.fetch_both(result) ifx_db.close(conn)
def run_test_066(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, config.user.lower(), 'animals') else: result = ifx_db.tables(conn, None, config.user.upper(), 'ANIMALS') # NOTE: This is a workaround # function fetch_object() to be implemented... # row = ifx_db.fetch_object(result) class Row: pass data = ifx_db.fetch_assoc(result) while (data): row = Row() if (server.DBMS_NAME[0:3] == 'IDS'): row.table_schem = data['table_schem'] row.table_name = data['table_name'] row.table_type = data['table_type'] row.remarks = data['remarks'] print "Schema: %s" % row.table_schem print "Name: %s" % row.table_name print "Type: %s" % row.table_type print "Remarks: %s\n" % row.remarks else: row.TABLE_SCHEM = data['TABLE_SCHEM'] row.TABLE_NAME = data['TABLE_NAME'] row.TABLE_TYPE = data['TABLE_TYPE'] row.REMARKS = data['REMARKS'] print "Schema: %s" % row.TABLE_SCHEM print "Name: %s" % row.TABLE_NAME print "Type: %s" % row.TABLE_TYPE print "Remarks: %s\n" % row.REMARKS # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, config.user.lower(), 'animal_pics') else: result = ifx_db.tables(conn, None, config.user.upper(), 'ANIMAL_PICS') # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) while (data): row = Row() if (server.DBMS_NAME[0:3] == 'IDS'): row.table_schem = data['table_schem'] row.table_name = data['table_name'] row.table_type = data['table_type'] row.remarks = data['remarks'] print "Schema: %s" % row.table_schem print "Name: %s" % row.table_name print "Type: %s" % row.table_type print "Remarks: %s\n" % row.remarks else: row.TABLE_SCHEM = data['TABLE_SCHEM'] row.TABLE_NAME = data['TABLE_NAME'] row.TABLE_TYPE = data['TABLE_TYPE'] row.REMARKS = data['REMARKS'] print "Schema: %s" % row.TABLE_SCHEM print "Name: %s" % row.TABLE_NAME print "Type: %s" % row.TABLE_TYPE print "Remarks: %s\n" % row.REMARKS # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, config.user.lower(), 'anime_cat') else: result = ifx_db.tables(conn, None, config.user.upper(), 'ANIME_CAT') # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) while (data): row = Row() if (server.DBMS_NAME[0:3] == 'IDS'): row.table_schem = data['table_schem'] row.table_name = data['table_name'] row.table_type = data['table_type'] row.remarks = data['remarks'] print "Schema: %s" % row.table_schem print "Name: %s" % row.table_name print "Type: %s" % row.table_type print "Remarks: %s\n" % row.remarks else: row.TABLE_SCHEM = data['TABLE_SCHEM'] row.TABLE_NAME = data['TABLE_NAME'] row.TABLE_TYPE = data['TABLE_TYPE'] row.REMARKS = data['REMARKS'] print "Schema: %s" % row.TABLE_SCHEM print "Name: %s" % row.TABLE_NAME print "Type: %s" % row.TABLE_TYPE print "Remarks: %s\n" % row.REMARKS # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) ifx_db.free_result(result) ifx_db.close(conn)
def run_test_156(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.exec_immediate(conn, "select * from staff") row = ifx_db.fetch_assoc(result) count = 1 while (row): if (row['YEARS'] == None): row['YEARS'] = '' if (row['COMM'] == None): row['COMM'] = '' print row['ID'], row['NAME'], row['JOB'], row['YEARS'], row[ 'SALARY'], row['COMM'] row = ifx_db.fetch_assoc(result) result2 = ifx_db.exec_immediate( conn, "select * from department where substr(deptno,1,1) in ('A','B','C','D','E')" ) row2 = ifx_db.fetch_assoc(result2) while (row2): if (row2['MGRNO'] == None): row2['MGRNO'] = '' print row2['DEPTNO'], row2['DEPTNAME'], row2['MGRNO'], row2[ 'ADMRDEPT'], row2['LOCATION'] row2 = ifx_db.fetch_assoc(result2) #__END__ #__LUW_EXPECTED__ #10 Sanders Mgr 7 18357.50 #20 Pernal Sales 8 18171.25 612.45 #30 Marenghi Mgr 5 17506.75 #40 OBrien Sales 6 18006.00 846.55 #50 Hanes Mgr 10 20659.80 #60 Quigley Sales 16808.30 650.25 #70 Rothman Sales 7 16502.83 1152.00 #80 James Clerk 13504.60 128.20 #90 Koonitz Sales 6 18001.75 1386.70 #100 Plotz Mgr 7 18352.80 #110 Ngan Clerk 5 12508.20 206.60 #120 Naughton Clerk 12954.75 180.00 #130 Yamaguchi Clerk 6 10505.90 75.60 #140 Fraye Mgr 6 21150.00 #150 Williams Sales 6 19456.50 637.65 #160 Molinare Mgr 7 22959.20 #170 Kermisch Clerk 4 12258.50 110.10 #180 Abrahams Clerk 3 12009.75 236.50 #190 Sneider Clerk 8 14252.75 126.50 #200 Scoutten Clerk 11508.60 84.20 #210 Lu Mgr 10 20010.00 #220 Smith Sales 7 17654.50 992.80 #230 Lundquist Clerk 3 13369.80 189.65 #240 Daniels Mgr 5 19260.25 #250 Wheeler Clerk 6 14460.00 513.30 #260 Jones Mgr 12 21234.00 #270 Lea Mgr 9 18555.50 #280 Wilson Sales 9 18674.50 811.50 #290 Quill Mgr 10 19818.00 #300 Davis Sales 5 15454.50 806.10 #310 Graham Sales 13 21000.00 200.30 #320 Gonzales Sales 4 16858.20 844.00 #330 Burke Clerk 1 10988.00 55.50 #340 Edwards Sales 7 17844.00 1285.00 #350 Gafney Clerk 5 13030.50 188.00 #A00 SPIFFY COMPUTER SERVICE DIV. 000010 A00 None #B01 PLANNING 000020 A00 None #C01 INFORMATION CENTER 000030 A00 None #D01 DEVELOPMENT CENTER A00 None #D11 MANUFACTURING SYSTEMS 000060 D01 None #D21 ADMINISTRATION SYSTEMS 000070 D01 None #E01 SUPPORT SERVICES 000050 A00 None #E11 OPERATIONS 000090 E01 None #E21 SOFTWARE SUPPORT 000100 E01 None #__ZOS_EXPECTED__ #10 Sanders Mgr 7 18357.50 #20 Pernal Sales 8 18171.25 612.45 #30 Marenghi Mgr 5 17506.75 #40 OBrien Sales 6 18006.00 846.55 #50 Hanes Mgr 10 20659.80 #60 Quigley Sales 16808.30 650.25 #70 Rothman Sales 7 16502.83 1152.00 #80 James Clerk 13504.60 128.20 #90 Koonitz Sales 6 18001.75 1386.70 #100 Plotz Mgr 7 18352.80 #110 Ngan Clerk 5 12508.20 206.60 #120 Naughton Clerk 12954.75 180.00 #130 Yamaguchi Clerk 6 10505.90 75.60 #140 Fraye Mgr 6 21150.00 #150 Williams Sales 6 19456.50 637.65 #160 Molinare Mgr 7 22959.20 #170 Kermisch Clerk 4 12258.50 110.10 #180 Abrahams Clerk 3 12009.75 236.50 #190 Sneider Clerk 8 14252.75 126.50 #200 Scoutten Clerk 11508.60 84.20 #210 Lu Mgr 10 20010.00 #220 Smith Sales 7 17654.50 992.80 #230 Lundquist Clerk 3 13369.80 189.65 #240 Daniels Mgr 5 19260.25 #250 Wheeler Clerk 6 14460.00 513.30 #260 Jones Mgr 12 21234.00 #270 Lea Mgr 9 18555.50 #280 Wilson Sales 9 18674.50 811.50 #290 Quill Mgr 10 19818.00 #300 Davis Sales 5 15454.50 806.10 #310 Graham Sales 13 21000.00 200.30 #320 Gonzales Sales 4 16858.20 844.00 #330 Burke Clerk 1 10988.00 55.50 #340 Edwards Sales 7 17844.00 1285.00 #350 Gafney Clerk 5 13030.50 188.00 #A00 SPIFFY COMPUTER SERVICE DIV. 000010 A00 None #B01 PLANNING 000020 A00 None #C01 INFORMATION CENTER 000030 A00 None #D01 DEVELOPMENT CENTER A00 None #D11 MANUFACTURING SYSTEMS 000060 D01 None #D21 ADMINISTRATION SYSTEMS 000070 D01 None #E01 SUPPORT SERVICES 000050 A00 None #E11 OPERATIONS 000090 E01 None #E21 SOFTWARE SUPPORT 000100 E01 None #__SYSTEMI_EXPECTED__ #10 Sanders Mgr 7 18357.50 #20 Pernal Sales 8 18171.25 612.45 #30 Marenghi Mgr 5 17506.75 #40 OBrien Sales 6 18006.00 846.55 #50 Hanes Mgr 10 20659.80 #60 Quigley Sales 16808.30 650.25 #70 Rothman Sales 7 16502.83 1152.00 #80 James Clerk 13504.60 128.20 #90 Koonitz Sales 6 18001.75 1386.70 #100 Plotz Mgr 7 18352.80 #110 Ngan Clerk 5 12508.20 206.60 #120 Naughton Clerk 12954.75 180.00 #130 Yamaguchi Clerk 6 10505.90 75.60 #140 Fraye Mgr 6 21150.00 #150 Williams Sales 6 19456.50 637.65 #160 Molinare Mgr 7 22959.20 #170 Kermisch Clerk 4 12258.50 110.10 #180 Abrahams Clerk 3 12009.75 236.50 #190 Sneider Clerk 8 14252.75 126.50 #200 Scoutten Clerk 11508.60 84.20 #210 Lu Mgr 10 20010.00 #220 Smith Sales 7 17654.50 992.80 #230 Lundquist Clerk 3 13369.80 189.65 #240 Daniels Mgr 5 19260.25 #250 Wheeler Clerk 6 14460.00 513.30 #260 Jones Mgr 12 21234.00 #270 Lea Mgr 9 18555.50 #280 Wilson Sales 9 18674.50 811.50 #290 Quill Mgr 10 19818.00 #300 Davis Sales 5 15454.50 806.10 #310 Graham Sales 13 21000.00 200.30 #320 Gonzales Sales 4 16858.20 844.00 #330 Burke Clerk 1 10988.00 55.50 #340 Edwards Sales 7 17844.00 1285.00 #350 Gafney Clerk 5 13030.50 188.00 #A00 SPIFFY COMPUTER SERVICE DIV. 000010 A00 None #B01 PLANNING 000020 A00 None #C01 INFORMATION CENTER 000030 A00 None #D01 DEVELOPMENT CENTER A00 None #D11 MANUFACTURING SYSTEMS 000060 D01 None #D21 ADMINISTRATION SYSTEMS 000070 D01 None #E01 SUPPORT SERVICES 000050 A00 None #E11 OPERATIONS 000090 E01 None #E21 SOFTWARE SUPPORT 000100 E01 None #__IDS_EXPECTED__ #10 Sanders Mgr 7 18357.50 #20 Pernal Sales 8 18171.25 612.45 #30 Marenghi Mgr 5 17506.75 #40 OBrien Sales 6 18006.00 846.55 #50 Hanes Mgr 10 20659.80 #60 Quigley Sales 16808.30 650.25 #70 Rothman Sales 7 16502.83 1152.00 #80 James Clerk 13504.60 128.20 #90 Koonitz Sales 6 18001.75 1386.70 #100 Plotz Mgr 7 18352.80 #110 Ngan Clerk 5 12508.20 206.60 #120 Naughton Clerk 12954.75 180.00 #130 Yamaguchi Clerk 6 10505.90 75.60 #140 Fraye Mgr 6 21150.00 #150 Williams Sales 6 19456.50 637.65 #160 Molinare Mgr 7 22959.20 #170 Kermisch Clerk 4 12258.50 110.10 #180 Abrahams Clerk 3 12009.75 236.50 #190 Sneider Clerk 8 14252.75 126.50 #200 Scoutten Clerk 11508.60 84.20 #210 Lu Mgr 10 20010.00 #220 Smith Sales 7 17654.50 992.80 #230 Lundquist Clerk 3 13369.80 189.65 #240 Daniels Mgr 5 19260.25 #250 Wheeler Clerk 6 14460.00 513.30 #260 Jones Mgr 12 21234.00 #270 Lea Mgr 9 18555.50 #280 Wilson Sales 9 18674.50 811.50 #290 Quill Mgr 10 19818.00 #300 Davis Sales 5 15454.50 806.10 #310 Graham Sales 13 21000.00 200.30 #320 Gonzales Sales 4 16858.20 844.00 #330 Burke Clerk 1 10988.00 55.50 #340 Edwards Sales 7 17844.00 1285.00 #350 Gafney Clerk 5 13030.50 188.00 #A00 SPIFFY COMPUTER SERVICE DIV. 000010 A00 None #B01 PLANNING 000020 A00 None #C01 INFORMATION CENTER 000030 A00 None #D01 DEVELOPMENT CENTER A00 None #D11 MANUFACTURING SYSTEMS 000060 D01 None #D21 ADMINISTRATION SYSTEMS 000070 D01 None #E01 SUPPORT SERVICES 000050 A00 None #E11 OPERATIONS 000090 E01 None #E21 SOFTWARE SUPPORT 000100 E01 None