[ic] return value of autonumber or code at time of INSERT

Mike Heins mike at perusion.com
Mon Aug 22 13:17:07 EDT 2005


Quoting maillists (lists at gmnet.net):
> HI,
> 
> I have searched the docs and mail list and I have not found the answer
> to this. I need to be able to get the value of the primary key made by
> autonumber or auto_increment at the time it is created.
> 
> Here is my scenario:
> 
> * user creates an account or logs in.
> 
> * user can insert a new record in a table via a form. call it tableA
> 
> * When the user inserts this record, into tableA, 2 things happen.
> 
>   1) user gets an email with the new record ID or code in the email. 
>   2) I update the value of a field in another table say tableB with the
> value of the ID or code from the new inserted record in tableA.
> 
> I know how to do all the inserts, email, and everything. I just can't
> figure out how to return the value code of tableA at the time it is
> created.
> 

Depends how you are creating the record.

If it is with embedded Perl, it is returned from set_slice:

	$Scratch->{new_key} = $db->set_slice(undef, \%record);

If it is with [table-editor] or mv_action=set, you should find [cgi
the_key] set to the new key value upon return from writing. You can
control where that value goes with mv_data_return_key, meaning if you
do in the table-editor:

	hidden.mv_data_return_key=foo

then [cgi foo] will contain the new key value.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Few blame themselves until they have exhausted all other possibilities.
 -- anonymous


More information about the interchange-users mailing list