
r.albanese at qut
Apr 19, 1999, 7:51 PM
Post #1 of 4
(192 views)
Permalink
|
--------------FA78C71110B61F82D85316D0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I am writing a web based database application and I am having problems in creating a string that contains an integer in it. I wish to store the login time as an integer so that I may do some time difference calculations based on the stored login time (ie. the integer). The SQL statement string creation fails when I have the integer variable "logtime" in it but not when it is removed. I believe that my problem is caused by trying to insert an integer into a string. The database works fine (ie I can add integers to the column "LogTime"). This is part of the code: . import dbi,odbc #For ODBC stuff import time #For ODBC and time related stuff import rexec #For executing the SQL query import cgi #For processing the form stuff import re #For regular expression and pattern matching #------------------------------------------------------------------------------------------------------- form = cgi.SvFormContentDict() . . . Caller=Ph=Loc=Sch=JbDes=JbPr=None Caller=form['Name'] Ph=form['PhNumb'] Loc=form['Locn'] Sch=form['Schl'] JbDes=form['JobDesc'] JbPr=form['urgency'] . . logtm=time.time() #a floating point logtime=int(logtm) #an integer . . frontpar='(' backpar=')' #Build the SQL statement string thesql="INSERT INTO CSJobs.compjobs (LogTime,Caller,Phone_Extension,Caller_Category,Location,Job_Description,Job_Priority,LogNumb,Log_Date,Finished) VALUES " thesql=thesql + frontpar + logtime + "," The inclusion of this variable ^ (ie logtime) causes this script to fail. When it is removed, it works ok. thesql= thesql + "'" + Caller + "'" + "," thesql=thesql + "'" + Ph + "'" + "," + "'" + Sch + "'" + "," thesql=thesql + "'" + Loc + "'" + "," + "'" + JbDes + "'" thesql=thesql + "," + "'" + JbPr + "'" + "," + "'" + LogN + "'" + "," + "'" + logdate + "'" + "," + "'" + "n" + "'" thesql=thesql + backpar thesql='"""' + thesql + '"""' thesql=frontpar + thesql + backpar thecode='crsr.execute' + thesql . . exec(thecode) Any suggestions as to what I am doing wrong?? Thanks in advance for any assistance. Rico --------------FA78C71110B61F82D85316D0 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> I am writing a web based database application and I am having problems in creating a string that contains an integer in it. I wish to store the login time as an integer so that I may do some time difference calculations based on the stored login time (ie. the integer). The SQL statement string creation fails when I have the integer variable "logtime" in it but not when it is removed. I believe that my problem is caused by trying to insert an integer into a string. The database works fine (ie I can add integers to the column "LogTime"). <p>This is part of the code: <br>. <br>import dbi,odbc #For ODBC stuff <br>import time #For ODBC and time related stuff <br>import rexec #For executing the SQL query <br>import cgi #For processing the form stuff <br>import re #For regular expression and pattern matching <p>#------------------------------------------------------------------------------------------------------- <p>form = cgi.SvFormContentDict() <br>. <br>. <br>. <br>Caller=Ph=Loc=Sch=JbDes=JbPr=None <br>Caller=form['Name'] <br>Ph=form['PhNumb'] <br>Loc=form['Locn'] <br>Sch=form['Schl'] <br>JbDes=form['JobDesc'] <br>JbPr=form['urgency'] <br>. <br>. <br>logtm=time.time() #a floating point <br>logtime=int(logtm) #an integer <br>. <br>. <br>frontpar='(' <br>backpar=')' <p>#Build the SQL statement string <p>thesql="INSERT INTO CSJobs.compjobs (LogTime,Caller,Phone_Extension,Caller_Category,Location,Job_Description,Job_Priority,LogNumb,Log_Date,Finished) VALUES " <br>thesql=thesql + frontpar + logtime + "," <br><font color="#CC0000">The inclusion of this variable ^ (ie logtime) causes this script to fail. When it is removed, it works ok.</font> <p>thesql= thesql + "'" + Caller + "'" + "," <br>thesql=thesql + "'" + Ph + "'" + "," + "'" + Sch + "'" + "," <br>thesql=thesql + "'" + Loc + "'" + "," + "'" + JbDes + "'" <br>thesql=thesql + "," + "'" + JbPr + "'" + "," + "'" + LogN + "'" + "," + "'" + logdate + "'" + "," + "'" + "n" + "'" <br>thesql=thesql + backpar <br>thesql='"""' + thesql + '"""' <br>thesql=frontpar + thesql + backpar <br>thecode='crsr.execute' + thesql <br>. <br>. <br>exec(thecode) <p>Any suggestions as to what I am doing wrong?? <p>Thanks in advance for any assistance. <p>Rico <br> </html> --------------FA78C71110B61F82D85316D0--
|