I built a function as following
def IsExists(fxfcustid):
#global noduplicates
db = db_connect("triumph","freight","vcpdb")
cursor = db2.cursor()
#*************************************************************************
#*** Query to get entries made by the person acessing the system ***
#*************************************************************************
sql = '''select count(*)
from triumph.fxf_salescontest_entry
where fxf_acct_nbr = %(fxfcustid)s)
and (delete_flag is null or
delete_flag not in ('Y','y')) ''' % vars()
try:
cursor.execute( sql )
noduplicates = cursor2.fetchall();
except:
noduplicates = [('None')]
cursor.close()
db.close()
return
### later on, it was called by followiging code:
isExists(fxfcustid)
if noduplicates != 0:
print mainscreen(empno,'This customer has been entered. Request failed',0,'')
else:
cursor.execute(insertSql % vars())
But it doesn't work. what's wrong with this code? is noduplicates number or string? any help is highly appreciated.
Thanks,
Jackie
Edit: code tags added by vegaseat