Gossamer Forum
Home : Products : DBMan : Customization :

? How to make a copy of a record to a new record

Quote Reply
? How to make a copy of a record to a new record
I want to make copies of one record to mod and save as an other record.
Is this something that can be done and if so how?
Thanks for any help.
Dave T
Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
This has been discussed before and no real solution was identified.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
I was playing with the code and found that
adding a button to file: html.pl
in the:
sub html_modify_form_record

I added this button inside the <form> tags:

<INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Copy Record as New" >

I bring up a record to modify. Make changes if I want and hit the "Copy Record as New" Button.
This will make a New record with the changes and leave the original unchanged.
and it writes to a new record no. Not over any records.
Go figure.
Thanks for any reply about any problems with this.

Dave T

Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
Hi Dave,

This sounds interesting, did you check the ID field (the counter field) to make sure the new record had a unique ID?

If so you may have stumbled on to somehting very cool.

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
NgtCrwlr,

If I delete record #25 out of a hundred records and bring up record #12 in Modify Record, make a copy, it will make new record #25. If I make a copy of this or any other records, it will make #101 if next... or fill in other deleted record numbers higher than record being copied.
So far no problems with unique ID Field #.

Thanks for your reply.
Dave T
Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
This works out pretty well for me as well... Except when you database starts to get a bit large... and you have multiple deletions and additions to the database. I started to get errors after awhile - nothing but a "this script produced no output". I tracked it down to the script searching the DB for a new DB_key. In the sub add_record in db.cgi, where is checks for the next available key, I needed to change the default time up quite a bit to 150 times before it gives up trying. Whew! It was frustrating because sometimes it would work, and sometimes it wouldn't! Changing this setting fixed it just fine! And it helps when you have quite a few items that need to be copied with multiple text fields.

Enjoy!
Dave
Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
this is a briliant one-line mod!
Quote Reply
Re: ? How to make a copy of a record to a new record In reply to
The code that Shoppe modified in db.cgi sub add_record was...
Code:
# We keep checking for the next available key, or until we've tried 50 times
# after which we give up.
while ($status eq "duplicate key error" and $db_key_track) {
return "duplicate key error" if ($counter++ > 50);
$in{$db_key}++;
$status = &validate_record;
}

Change: if ($counter++ > 50);
to this: if ($counter++ > 150);

or higher.

Thank you for your help Shoppe,

Dave T

[This message has been edited by Dave T (edited February 02, 2000).]