logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Re: A new way to do form processing: msg#00213

Subject: Re: Re: A new way to do form processing
On Sat, 23 Oct 2004 03:42:27 +0000 (UTC), Mark Stosberg
<mark@xxxxxxxxxxxxxxx> wrote:
> On 2004-10-23, Drew Taylor <taylor.andrew.j@xxxxxxxxx> wrote:
> >
> > I'm curious how you've handled code that adds a new row in the
> > database. What do you do to prevent a refresh from adding a duplicate
> > entry? The redirect is a simple solution that solves a common problem:
> 
> One option is to "pre-select" the unique ID so that it is present in the
> submission form. It can't be interested twice because that violates the
> primary key uniqueness.

That is an interesting idea, but at first glance it seems rather messy
in terms of database entries. You have to make sure your code catches
the duplicate key error. If you have generalized it, how did you go
about it and where did you put it? Controller (CGI::App) or Model
(Class::DBI, etc)?
 
> Sure, you may end up with more gaps in your unique ID sequence in the
> database, but IDs are cheap.

Gaps aren't a problem. But blank entries could potentially be one. How
do you determine a "preselected" entry from a "real" one? A flag? Do
you clean up these blank entries at some point? I'm using Class::DBI,
so I also have to worry about constraints, triggers, etc.

Drew
-- 
----------------------------------------------------------------
 Drew Taylor                 *  Web development & consulting
 Email: drew@xxxxxxxxxxxxxx  *  Site implementation & hosting
 Web  : www.drewtaylor.com   *  perl/mod_perl/DBI/mysql/postgres
 ----------------------------------------------------------------

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>