6 Replies Latest reply on Feb 16, 2010 6:25 PM by -==cfSearching==-

    Updating db records with createUUID() with CFLOOP

    sbudlong Level 1

      I have 7

      00 subscribers in a db, and I've created a new column 'token' and I want to create a unique UUID for each row. Something like this, although this doesn't work. These are just tests on a test db with 15 records.

       

      <cfquery datasource="maillist" name="createtoken">
       
          UPDATE subscribers
      <cfloop from = "1" to = "15" index="token" step="1">
      SET token =
      <cfqueryparam cfsqltype="cf_sql_varchar" value="#createUUID()#">
      </cfloop>

      </cfquery>

       

      OR

       

      <cfloop from="1" to="15" step="1" index="i">
      <cfquery datasource="maillist">
       
          UPDATE subscribers

      SET token = <cfqueryparam cfsqltype="cf_sql_varchar" value="#createUUID()#">

      </cfquery>
      </cfloop>

       

      I've been able to run the #createUUID()#" but it puts the same UUID in each row. Is is possible to UPDATE with unique UUIDs in every row?