![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello; For this scheduling app I'm trying to make for my little photography company... I would like to assign a unique, incrementing number to records in my database, but NOT at the time the record is created. |
#3
| |||
| |||
|
|
Easy. Use the regular key as just that - the standard key - and create another column in the table which you can edit, assign, etc etc, as you please :-) In some "configuration" table, keep the number for log jobs.. Run a cron job on January 1st to reset the number to 100. --~--~---------~--~----~------------~-------~--~----~ |
#4
| |||
| |||
|
|
Thanks Aldric; I think I'm stuck on the mechanics (if you can call it that in a software app) of prompting for a number to be inserted into a database column on demand, in an edit view. Maybe you addressed that and I'm too slow to have caught what you meant. BTW, I do already have a log_number column in my table. Just can't come up with a solution for how to populate it. |
#5
| |||
| |||
|
|
I'd advise you to drop this idea altogether and just use the primary key. *You'll be in for fewer headaches if you have one unambiguous identifier. --~--~---------~--~----~------------~-------~--~----~ |
#6
| |||
| |||
|
|
Hello Marnen, I appreciate your insight - it sounds like the voice of experience to me. :-) I don't actually intend to use this "log_number" attribute as a key in the database. An Assignment will always be unambiguously identified by the id it was "born" with. The log number is important in the analog end of our business, but as far as the database goes it's of similar importance to, say, the floor number in the client's shipping address if that makes sense. |
#7
| |||
| |||
|
|
Then stop using the log_number in the analog end! |
#8
| |||
| |||
|
|
Thanks Aldric; I think I'm stuck on the mechanics (if you can call it that in a software app) of prompting for a number to be inserted into a database column on demand, in an edit view. Maybe you addressed that and I'm too slow to have caught what you meant. |
|
BTW, I do already have a log_number column in my table. Just can't come up with a solution for how to populate it. The idea of a configuration table is a good one, as is the cron reset. Steve On Nov 5, 12:41Â*pm, Aldric Giacomoni <rails-mailing-l...@andreas- s.net> wrote: Easy. Use the regular key as just that - the standard key - and create another column in the table which you can edit, assign, etc etc, as you please :-) In some "configuration" table, keep the number for log jobs.. Run a cron job on January 1st to reset the number to 100. |
#9
| |||
| |||
|
|
Thanks Aldric; I think I'm stuck on the mechanics (if you can call it that in a software app) of prompting for a number to be inserted into a database column on demand, in an edit view. Maybe you addressed that and I'm too slow to have caught what you meant. BTW, I do already have a log_number column in my table. Just can't come up with a solution for how to populate it. The idea of a configuration table is a good one, as is the cron reset. |
#10
| |||
| |||
|
|
You could avoid the cronjob if you had a column for the year and one for the number and then just find_or_create_by_year the right record and increment the number by one (it could have a default (means also initial) value of 99). Regards T. |
![]() |
| Thread Tools | |
| Display Modes | |
| |