def run_test_spinout_timestamp(self): conn = IfxPy.connect(config.ConnStr, config.user, config.password) # Get the server type serverinfo = IfxPy.server_info(conn) if conn: drop = "DROP PROCEDURE PROC_TIMESTAMP" try: result = IfxPy.exec_immediate(conn, drop) except: pass # Create the SP with timestamp parameters create = "CREATE PROCEDURE PROC_TIMESTAMP ( INOUT PAR1 DATETIME YEAR TO FRACTION(5), OUT PAR2 DATETIME YEAR TO FRACTION(5)) LET PAR2 = PAR1; END PROCEDURE" result = IfxPy.exec_immediate(conn, create) # call the SP. Expect PAR2 to contain value passed to PAR1 par1 = "2017-05-13 22:47:29.82688" par2 = "" print "Values of bound parameters _before_ CALL:" print " 1: %s 2: %s\n" % (par1, par2) stmt, par1, par2 = IfxPy.callproc(conn, 'proc_timestamp', (par1, par2)) if stmt is not None: print "Values of bound parameters _after_ CALL:" print " 1: %s 2: %s\n" % (par1, par2) IfxPy.close(conn) else: print("Connection failed.")
def run_test_148(self): conn = IfxPy.connect(config.ConnStr, config.user, config.password) if conn: ##### Set up ##### serverinfo = IfxPy.server_info( conn ) server = serverinfo.DBMS_NAME[0:3] try: sql = "DROP TABLE sptb" IfxPy.exec_immediate(conn, sql) except: pass try: sql = "DROP PROCEDURE sp" IfxPy.exec_immediate(conn, sql) except: pass sql = "CREATE TABLE sptb (c1 INTEGER, c2 FLOAT, c3 VARCHAR(10), c4 INT8, c5 VARCHAR(20))" IfxPy.exec_immediate(conn, sql) sql = "INSERT INTO sptb (c1, c2, c3, c4, c5) VALUES (1, 5.01, 'varchar', 3271982, 'varchar data')" IfxPy.exec_immediate(conn, sql) sql = """CREATE PROCEDURE sp(OUT out1 INTEGER, OUT out2 FLOAT, OUT out3 VARCHAR(10), OUT out4 INT8, OUT out5 VARCHAR(20)); SELECT c1, c2, c3, c4, c5 INTO out1, out2, out3, out4, out5 FROM sptb; END PROCEDURE;""" IfxPy.exec_immediate(conn, sql) ############################# ##### Run the test ##### out1 = 0 out2 = 0.00 out3 = "" out4 = 0 out5 = "" stmt, out1, out2, out3, out4, out5 = IfxPy.callproc(conn, 'sp', (out1, out2, out3, out4, out5)) print("out 1:") print(out1) print("out 2:") print(out2) print("out 3:") print(out3) print("out 4:") print(out4) print("out 5:") print(out5) ############################# else: print("Connection failed.")
def run_test_146(self): conn = IfxPy.connect(config.ConnStr, config.user, config.password) server = IfxPy.server_info( conn ) if conn: name = "Peaches" second_name = "Rickety Ride" weight = 0 print("Values of bound parameters _before_ CALL:") print(" 1: %s 2: %s 3: %d\n" % (name, second_name, weight)) stmt, name, second_name, weight = IfxPy.callproc(conn, 'match_animal', (name, second_name, weight)) if stmt is not None: print("Values of bound parameters _after_ CALL:") print(" 1: %s 2: %s 3: %d\n" % (name, second_name, weight))