• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using CFLOCK for data Integrity

New Here ,
May 08, 2017 May 08, 2017

Copy link to clipboard

Copied

I plan to run the following two processes. In order to maintain data consistency I plan to use CFLOCK. I've never use CFLOCK in the past and not sure if this is going to work in maintaining data integrity. Please advise.

   <cflock scope = "Session" timeout = "30" type = "Exclusive">    

            <cfexecute name="SomeName" arguments ="#PathToFile#  #PathToLogfile#" errorFile="#PathToErrorFileLog#" outputFile="#PathToOutPutFileLog#"

             timeout="300></cfexecute>

       

            <cfquery name="UpdateUserID">

              Update TempTable

              SET UserID = '#session.userid#'

              WHERE NVL(userid,' ') = ' '

           </cfquery>

     </cflock>

cfexecute is inserting data from a text file into a temp table.

There is one column in temp table that is not in the text file and that column is UserId column.

Aftr Oracle sqlldr inserting all data from text file to the temp table, I update userid column in temp table to the session.userid. This way I know who own the data after the process is done.

TOPICS
Getting started

Views

452

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 16, 2017 May 16, 2017

Copy link to clipboard

Copied

LATEST

sylviam23155084 wrote:

..update userid column in temp table to the session.userid. This way I know who own the data after the process is done.

You apparently want that no two users should be able to access the code simultaneously. If so, then you should perhaps not be using the session lock. A session lock prevents two separate requests in the same user-session from accessing the code simultaneously.

You could use a named lock. For example,

<cflock name = "someUniqueName" timeout = "30" type = "Exclusive">

<cfexecute>

</cfexecute>

<cfquery>

</cfquery>

</cflock>

A good reference is: https://www.raymondcamden.com/2011/05/16/Why-and-how-to-lock-file-operations-in-ColdFusion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation