| | |
Function calling- numeric or char
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2005
Posts: 2
Reputation:
Solved Threads: 0
I built a function as following
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
Python Syntax (Toggle Plain Text)
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
Well jchang, I am not exacly sure where the problem is ,but can u check on the following syntax in your code... Hope it helps
In the main code where u call this function
isExists(fxfcustid) is actually supposed to be "IsExists(fxfcustid)"
functions are case sensitive...But if you are not facing a problem here, maybe the next one could be bothering...
I have never used three ' ' ' ( and I have no idea how it works)
In your code
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()
Here 'fxcustid' seems to be caught within the string, I mean it has become a part of the string... why dont u try
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()
I have very little knowledge in SQL Queries, I dont know whether the above syntax is right, hope it helps you in some way...
In the main code where u call this function
isExists(fxfcustid) is actually supposed to be "IsExists(fxfcustid)"
functions are case sensitive...But if you are not facing a problem here, maybe the next one could be bothering...
I have never used three ' ' ' ( and I have no idea how it works)
In your code
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()
Here 'fxcustid' seems to be caught within the string, I mean it has become a part of the string... why dont u try
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()
I have very little knowledge in SQL Queries, I dont know whether the above syntax is right, hope it helps you in some way...
![]() |
Similar Threads
- Function to convert integer to single char. (C)
- function calling problem (C)
- Passing char * to function and populating inside (C++)
- Object-Oriented Programming (C++)
- AnsiString Template Data Return Problem Builder 6 (C++)
- program help (C)
- Data Abstraction (Computer Science)
Other Threads in the Python Forum
- Previous Thread: Segmentation fault
- Next Thread: Merging Dictionary
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment backend beginner binary book builtin calculator character chmod converter countpasswordentry curved customdialog dan08 dictionaries dictionary drive dynamic examples exe file filename float format function gui heads homework import inches input java launcher library line lines linux list lists loop mouse mysql mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame pysimplewizard python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tkinter tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable windows wordgame write wxpython





