Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Generating a sequential reference # for form submittals

Posted on 2003-03-19
4
Medium Priority
?
147 Views
Last Modified: 2013-12-24
Hi,

This is my dilema.  I need to be able to generate a sequential reference # for every form that is submitted through my site to my email and also to the person submitting the email.  They both need to be the same number.  I cannot use the CreateUUID() or the Random Numbers.  I need the reference # to be something along the lines starting at 2003001 (2003 designating the year and the 001 would consecutively increase into it reaches 500).  Any help would be greatly appreciated. Please be as specific as possible.  thanks.
0
Comment
Question by:hotnixon2000
3 Comments
 
LVL 5

Expert Comment

by:JimV_ATL
ID: 8169485
<cfset timestamp = DateFormat(now(),"yyyymmdd") & TimeFormat(now(),"HHmmss")>

The above will create a number in the format 20030319154101.  I find this to be very helpful.  Perhaps it would work for you.
0
 
LVL 8

Accepted Solution

by:
TallerMike earned 200 total points
ID: 8169515
For it to be a truely sequential non-repeating number... you'll need to store this value in a DB somewhere. Then you'll need to query the next ID from the DB everytime you want a new one. If you're storing the form submissions in the DB, simply add a column to the DB that will house the ID. Then when you want a new ID, you'll need to do the following:

<cftransaction isolation="SERIALIZEABLE">
  <cfquery name="getNextID">
    SELECT MAX(ID)+1 AS nextID
    FROM TableName
  </cfquery>
  <cfset nextID = getNextID.nextID>
</cftransaction>

Alternatively, you could have a table where you simply house your sequential IDs, like so:

<cftransaction isolation="SERIALIZEABLE">
  <cfquery name="getNextID">
    SELECT MAX(ID)+1 AS nextID
    FROM IDTable
  </cfquery>
  <cfquery name="getNextID">
    UPDATE IDTable
    SET ID = ID + 1
  </cfquery>
  <cfset nextID = getNextID.nextID>
</cftransaction>

************************************************************************************************
************************************************************************************************

Another risky solutiuon is to use an application variable. like so:

<cfloop type="Application">
  <cfparm name="Application.mySeq" default="2003001">
  <cfset nextID = Application.mySeq>
  <cfset Application.mySeq = Application.mySeq + 1>
</cflock>

The problem with this is that when the server is rebooted, you loose this value.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10940752
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation in the Cleanup topic area:

Accept TallerMike

Please leave any comments here within the next four days.

mrichmon
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question