This topic is locked

Primary Key generation (record ID)

6/15/2004 2:39:54 PM
ASPRunnerPro General questions
author

I'm currently testing ASPRunner Pro for my company, and my manager wants to make sure the unique record ID is generated in this format "YYYYMMDDNNNN". The first 8 numbers are just the current date the record is generated, and the last 4 numbers would be the records generated that day. For example, I'm inputing a record into the database today, and I'm the first user to make a data entry for today, and my record ID would be automatically generated as "200406150001". Is there any way I could do that? Please help

Sergey Kornilov admin 6/18/2004

I guess you need to create a separate table which should hold last created record number for each day (or just for todays date). Also you need a separate stored procedure/query that will generate unique record ID based on your rules. Unfortunately ASPRunner won't help you doing this.

B
BJones 9/3/2004

You could write a custom funtion that generates the key for you. In Asprunner mark the primary key field by using the 'Edit as' command to a text field and then use the 'Change as' to set the default value to a function name like this: GetNextID().
Now create an ASP function that returns the ID in any format you want. In your case I would probably select the MAX + 1 on the last four characters of the primary key field and append that to today's date.
The only problem with this procedure is I haven't found a way to make a text field visible but read only in ASPRunner without going in and tweaking the generated code.