how to use if statement with return to check if the function returns value when calling stored proc using python
Question:
i need to check the value with return if getting some value when calling procedure in python
` i need to check the value with return if getting some value when calling procedure in python`
def get_order_count(salesman_id, year):
try:
# create a connection to the Oracle Database
with cx_Oracle.connect(cfg.username,
cfg.password,
cfg.dsn,
encoding=cfg.encoding) as connection:
# create a new cursor
with connection.cursor() as cursor:
# create a new variable to hold the value of the
# OUT parameter
order_count = cursor.var(int)
# call the stored procedure
cursor.callproc('get_order_count',
[salesman_id, year, order_count])
return order_count.getvalue()
except cx_Oracle.Error as error:
print(error)
if order_count ==1
print ('succesesfull' )
else:
pass
Answers:
so inside a procedder there was if stament to check if run right then will return 1 if not 0 so we assing that to int value and then use it when calling procedure
if order_count ==1:
print ('succesesfull' )
elif: order_count ==0:
print('faild')
else:
pass ```
i need to check the value with return if getting some value when calling procedure in python
` i need to check the value with return if getting some value when calling procedure in python`
def get_order_count(salesman_id, year):
try:
# create a connection to the Oracle Database
with cx_Oracle.connect(cfg.username,
cfg.password,
cfg.dsn,
encoding=cfg.encoding) as connection:
# create a new cursor
with connection.cursor() as cursor:
# create a new variable to hold the value of the
# OUT parameter
order_count = cursor.var(int)
# call the stored procedure
cursor.callproc('get_order_count',
[salesman_id, year, order_count])
return order_count.getvalue()
except cx_Oracle.Error as error:
print(error)
if order_count ==1
print ('succesesfull' )
else:
pass
so inside a procedder there was if stament to check if run right then will return 1 if not 0 so we assing that to int value and then use it when calling procedure
if order_count ==1:
print ('succesesfull' )
elif: order_count ==0:
print('faild')
else:
pass ```