Hi Paris,

I'd recommend using cftry / cfcatch.  Credit for the info below goes to
Steve Nelson.  He's discussing his cf_max_id tag.  Hope this helps.

Jay

What about locking issues?  

Microsoft Access in particular may throw errors if you use this tag if
simultaneous people try
and create records at the same time, even if you use the cftransaction
tag and/or the cflock tag.  If that is 
happening, you should probably upgrade to SQL Server or another
multi-user database engine.

But, in the mean time, let CF error handling fix this problem for you.
(this is sooo slick :)

<cfloop condition="true">
        <cftry>
                <cftransaction>
                        <cf_max_ID 
                                datasource="#application.mainDSN#"
                                tablename="users"
                                primarykey="userid">
                  
                        <cfquery name="addhistory"
datasource="#application.mainDSN#">
                                insert into
users(userid,firstname,lastname,email)
        
values(#max_ID#,'#trim(attributes.firstname)#','#trim(attributes.lastnam
e)#','#attributes.email#')
                        </cfquery>
                </cftransaction>

                <cfbreak>
                <cfcatch type="database">

                </cfcatch>
        </cftry>
</cfloop>
-----Original Message-----
From: Paris Lundis [mailto:[EMAIL PROTECTED]] 
Sent: Monday, August 06, 2001 11:19 PM
To: CF-Talk
Subject: Lock the database?


So I have some code that logs page information on every page and across 
multiple servers...

The idea is to slap the data into Access and fold a database file a day 
vs. the overhead and in box disk issues with SQL Server.. not to 
mention cost...

Scenario....

2 users access a page... one on SERVER A the other on SERVER B... Same
code .. same database (Access) in both and stored on a NAS storage 
device...

Both folks go to the page at the same time...

<cfquery name="logactivity" datasource="logger">
   update dailyimpressions
   where record = #record#
</cfquery>

Now that work across a few million pages a month, but generate a few - 
50-100 errors a day of :

ODBC Error Code = S1000 (General error)
[Microsoft][ODBC Microsoft Access Driver] Could not update; currently 
locked by user 'adm' on machine 'CRAPO1'.


SQL = "insert into dailyimpressions.... ETC.

WHat would any of you recommend to lock the database call /reduce 
errors spun out?

Interested in hearing everyone's input... Locks.. ehh...

-paris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to