[ic] record created, but cant retrieve autonumber value on next page

Kevin Walsh interchange-users@icdevgroup.org
Thu Aug 22 19:51:01 2002


> 
> on a form-to-table page, I have the following (copied from
> the UI pages) that will grab the autonumber:
> 
> [if cgi new]
> [perl tables="quote"]
> 	my $db = $Db{$CGI->{quote}} or return;
> 	unless ($db->config('AUTO_SEQUENCE')) {
> 		$db->config('AUTO_NUMBER', '000001')
> 			unless $db->config('AUTO_NUMBER');
> 		$CGI->{item_id} = $db->autonumber();
> 	}
> 	return;
> [/perl]
> [/if]
> 
> [set update_database]... etc. etc.
> <form ..etc. etc..>
> <input type=hidden name=code value="[cgi code]">
> 
> the record is created just fine!
> 
> but on the next page all of my values carry through except the
> "code" - I tried [cgi code] and [value code] and either one
> returns a blank even though the record was already created
> by this point.  How do you grab that value??
> 
Perhaps I've not understood what you've written, but it seems to me
that you should be using [cgi item_id] instead of [cgi code].

On another note, something that could cause future problems is your
use of the %Db hash in the following:

    [perl tables="quote"]
        my $db = $Db{$CGI->{quote}} or return;

Shouldn't the "tables" parameter be set dynamically too, so the
two lines read more like this:

    [perl tables="[cgi quote]"]
        my $db = $Db{$CGI->{quote}} or die 'Useful error message';

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/