Hi Mike: I think that this code have many possibilities to fail, it's not encapsulated. I comment on every aspect based on what I can see, and some asumptions of what I can't see:
1) You do "INSERT INTO (this.cAuditDBF) ...", but I don't see you first open the table (this.cAuditDBF) with USE command, which is not good practice and leave the SQL to open the table in no specific way. You probably are opening this table externally, but then it's not encapsulated on the function, so you are assuming it's open, and if it isn't, then the INSERT will open it, which is not ok. 2) What is the difference between (this.cAuditDBF) and (this.GetTableName('audit'))? Are both different Audit table names? 3) Error CATCHING do nothing, you don't even log the error in a text file with STRTOFILE() 4) This LOG/Audit function should be in a session class (as PRG), so it's functionality and tables are encapsulated and well separated from the tables of the system. 5) The LOG/Audit function should open/close his tables, but here, I can't see if this function is part of a LOG/Audit class that do this on another method. Is not easy trying to say what is wring if can't see the complete LOG/Audit implementation, so I may be wrong on some assumptions. Best Regards.- 2015-08-11 5:20 GMT+02:00 <mbsoftwaresoluti...@mbsoftwaresolutions.com>: > Well, I should confess that it's some bug in this code of mine, although > I've retooled this to totally eliminate the DBF file and just go right to > my backend (MySQL). This was the old code. No doubt I had something > assumed/wrong with my DBF table: > > FUNCTION Audit(tcFormName as String, tcUniqueID as String, tlEntering as > Logical, tcUserID as String, tcSessionID as String) as Logical > * Audits form usage. > *** mjb 05/15/2014 - using local audit table so no remote database > connection needed at startup; will be > *** mjb 01/07/2015 - using PRIVATE vars in INSERT cmd > *** mjb 07/29/2015 - changed local name to match for client > LOCAL llOK as Logical, lcSQL as String, loException as Exception, > lcLocal as String, liHandle as Integer > PRIVATE pcUserID, pcModule, pcUniqueID, pcSessionID > TRY > liHandle = this.GetHandle() && mjb 07-29-15 > lcLocal = ADDBS(JUSTPATH(this.cAuditDBF)) + > this.GetTableName('audit') + ".dbf" > IF NOT FILE(lcLocal) THEN > CREATE TABLE (lcLocal) (user c(16), module c(30), > uniqueid c(10), sessionid c(10), entering l, uploaded l, tlocal t) > ENDIF > USE IN (SELECT(JUSTSTEM(lcLocal))) && make sure not > exclusive > > IF VARTYPE(tcUserID) = "C" AND NOT EMPTY(tcUserID) THEN > pcUserID = tcUserID > ELSE > *** mjb 07/29/2015 - adjusted for startup call > from main where oUtils.oUser not yet existing > IF TYPE("oUtils.oUser") = "O" THEN > pcUserID = ALLTRIM(oUtils.oUser.cID) > ELSE > pcUserID = SYS(0) > ENDIF > ENDIF && VARTYPE(tcUserID) = "C" AND NOT EMPTY(tcUserID) > IF PEMSTATUS(_screen,"cUniqueID",5) THEN > pcSessionID = _screen.cUniqueID > ELSE > pcSessionID = 'unknown' > ENDIF > ltLocal = DATETIME() > IF VARTYPE(tcUniqueID) = "C" AND NOT EMPTY(tcUniqueID) THEN > pcUniqueID = tcUniqueID > ELSE > pcUniqueID = '' > ENDIF && VARTYPE(tcUniqueID) = "C" AND NOT > EMPTY(tcUniqueID) > > INSERT INTO (this.cAuditDBF) (user, module, uniqueid, > sessionid, entering, tlocal) ; > VALUES (pcUserID, ALLTRIM(tcFormName), pcUniqueID, > pcSessionID, tlEntering, ltLocal) > > IF liHandle > 0 THEN > lcTable = this.GetTableName('audit') > TEXT TO lcSQL PRETEXT 15 NOSHOW TEXTMERGE > INSERT INTO <<lcTable>> (user, module, > uniqueid, sessionid, entering, tlocal) > VALUES > (?pcUserID,'<<ALLTRIM(tcFormName)>>',?pcUniqueID,?pcSessionID,<<IIF(tlEntering,1,0)>>,'<<TTOC(ltLocal,1)>>') > ENDTEXT > llOK = this.ExecuteSQL(lcSQL) = 1 > IF llOK THEN > REPLACE uploaded WITH .T. IN > (JUSTSTEM(this.cAuditDBF)) > ELSE > SET STEP ON > ENDIF && llOK > ENDIF > CATCH TO loException > llOK = .F. > *SET STEP ON > ENDTRY > RETURN llOK > ENDFUNC && Audit(tcFormName as String, tcUniqueID as String, tlEntering as > Logical, tcUserID as String, tcSessionID as String) as Logical > > > Thanks again to all of you who chimed in! > [excessive quoting removed by server] _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/CAGQ_Junj3RXnmAhArJ58O+_Rs=d5jjnfwn7sqk7v7r1whhx...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.