def run_test_240(self): conn = ibm_db.connect(config.database, config.user, config.password) result = ibm_db.exec_immediate(conn, "select * from sales") result2 = ibm_db.exec_immediate(conn, "select * from staff") result3 = ibm_db.exec_immediate(conn, "select * from emp_photo") for i in range(0, ibm_db.num_fields(result)): print(str(i) + ":" + str(ibm_db.field_width(result, i))) print("\n-----") for i in range(0, ibm_db.num_fields(result2)): print( str(i) + ":" + str(ibm_db.field_width(result2, ibm_db.field_name(result2, i))) ) print("\n-----") for i in range(0, 3): print( str(i) + ":" + str(ibm_db.field_width(result3, i)) + "," + str(ibm_db.field_display_size(result3, i))) print("\n-----") print("region:%s" % ibm_db.field_type(result, 'region')) print("5:%s" % ibm_db.field_type(result2, 5))
def run_test_241(self): conn = ibm_db.connect(config.database, config.user, config.password) result = ibm_db.exec_immediate(conn, "select * from sales") result2 = ibm_db.exec_immediate(conn, "select * from staff") result3 = ibm_db.exec_immediate(conn, "select * from emp_photo") for i in range(0, ibm_db.num_fields(result)): print(str(ibm_db.field_width(result,i))) print("\n-----") for i in range(0, ibm_db.num_fields(result2)): print(str(ibm_db.field_width(result2,ibm_db.field_name(result2,i))))
def run_test_240(self): conn = ibm_db.connect(config.database, config.user, config.password) result = ibm_db.exec_immediate(conn, "select * from sales") result2 = ibm_db.exec_immediate(conn, "select * from staff") result3 = ibm_db.exec_immediate(conn, "select * from emp_photo") for i in range(0, ibm_db.num_fields(result)): print(str(i) + ":" + str(ibm_db.field_width(result,i))) print("\n-----") for i in range(0, ibm_db.num_fields(result2)): print(str(i) + ":" + str(ibm_db.field_width(result2,ibm_db.field_name(result2,i)))) print("\n-----") for i in range(0, 3): print(str(i) + ":" + str(ibm_db.field_width(result3,i)) + "," + str(ibm_db.field_display_size(result3,i))) print("\n-----") print("region:%s" % ibm_db.field_type(result,'region')) print("5:%s" % ibm_db.field_type(result2,5))
# Otherwise, Complete The Status Message else: print("Done!\n") # Display A Report Header print("Result set information:\n") print("COLUMN NAME MAXIMUM VALUE SIZE (IN BYTES)") print("_____________ _____________________________") # As Long As There Is Column Information, ... for loopCounter in range(0, numColumns): # Get The Name Of The Current Column colName = ibm_db.field_name(resultSet, loopCounter) # Get The Size Of The Data Allowed In The Current Column colWidth = ibm_db.field_width(resultSet, loopCounter) # Format And Display The Data Retrieved if (not colName is False) and (not colWidth is False): print("{:<13} {:>29}".format(colName, colWidth)) # Add A Blank Line To The End Of The Report print() # Close The Database Connection That Was Opened Earlier conn.closeConnection() # Return Control To The Operating System exit()