Gossamer Forum
Home : Products : DBMan : Installation :

Making a "COPY" of a record?

Quote Reply
Making a "COPY" of a record?
Here's one I can't seem to find an answer for.....

Can anyone tell me if it is possible to make a copy of a record? Why you ask?! Anyone who has entered a LOT of records that may only have one slight variance from a previous record knows! It can drive you insane re-entering duplicate info over and over!

An example of this is our Music Users Group - we trade CD's and LP's based on music Style or type (Jazz, Classical, Rock, etc). Obviously, many artists cross over the lines and can have multiple "types". So it is not uncommon to enter the exact same information for another record except for maybe the the category or style type. It would be so great to just hit a "Dulpicate" or "copy" link and have it contain all the same info as the original but with a new record ID. Then all that would be necessary to do would be to change the Style type field without re-entering any of the other info.

We experimented with just modifying the record that we wanted to copy by giving it a new record ID. It worked great assuming we knew what the last record ID that was used was, otherwise, we ran the risk of overwritting another record.

Any ideas how to do this? Thanks in advance!

Liverpool
Quote Reply
Re: Making a "COPY" of a record? In reply to
Some other DBMAN users have experienced the same challenges as you are. Carol was working on a mod to change the db_key routines, so that dup records could be added with the same key value as well as different key values.

I hope that she returns to the Forum soon. She may be able to help you.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Making a "COPY" of a record? In reply to
Thanks for the feedback Elliot. I'm gonna look into this db_key concept...

Regarding JPDeni,


[SNIP] She's Back! Hallelujah!

Your own attempts to jump in and help people while JPDeni is under the weather have been admirable. As well as are the ways you've implimented DBman at anthrotech.com.

Thanks again!

Liverpool

[This message has been edited by liverpool (edited September 25, 1999).]
Quote Reply
Re: Making a "COPY" of a record? In reply to
Hey JPDeni!

It is so good to see you back with a vengence! I've just been following you around seeing what kind of aid you are offering to folks....you are too cool! Fixed two of my problems just listening in on your answers to other problems that you shared!

This copying problem might be too obscure for you to tackle. Any thoughts, though, on where I'd start screwing around to atleast TRY to make soemthing like this happen?

Thanks! And welcome back!

Liverpool

p.s.
you're "da bomb!"
Quote Reply
Re: Making a "COPY" of a record? In reply to
Thank you for the nice words. Smile

I was sorta staying out of this because Eliot was handling it. But I'll be glad to tell you what I did.

My site (the one I first picked up DBMan for) is for support of grieving parents. The original purpose of DBMan was to maintain a memorial list for children who had been lost. Unfortunately, there are a lot of parents out there who have lost more than one child.

I need to update my site, since I've learned a lot since I put it up, but at present, after a parent enters the information about a child, there is a link on the add_success page to "Add another child." I didn't want parents to have to enter their own name, email address, and other info a second time.

I changed:

&html_record(&get_record($in{$db_key}));

to

%rec = &get_record($in{$db_key});
&html_record(%rec);

And I added this to sub html_add_success, after the display of the record that was just entered:

Code:
$rec{'parent'} =~ s/&/and/g;
$rec{'parent'} =~ s/ /+/g;
$rec{'last'} =~ s/ /+/g;
$rec{'ID'} = $rec{'ID'} + 1;
$rec{'date'} = &get_date;
print qq|<a href=$db_script_link_url&add_form=1&another=1&ID=$rec{'ID'}&date=$rec{'date'}&parent=$rec{'parent'}
&email=$rec{'email'}&last=$rec{'last'}&sur=$rec{'sur'}&link=$rec{'link'}&list=$rec{'list'}
&disc=$rec{'disc'}&$mul=Yes">
Click here to add another child.</A></font>|;

A couple of things to note:
Any values that might have special characters or spaces in them must be encoded. If you are not likely to have special characters, such as @#$%^&* in the values, you can do what I did above:

$rec{'parent'} =~ s/ /+/g;
$rec{'last'} =~ s/ /+/g;

If you are likely to have other characters that might mess up a URL, you'll need to pick up sub urlencode from [urlhttp://www.jpdeni.com/dbman/Mods/changes.txt[/url]. I'll explain how to use it if you're going to need it.

I added 1 to the counter for the ID.

Each of the fields that you want to copy from one record to the other must be included in the URL.

The thing that makes this work is a little change in sub html_add_form.

Instead of

&html_record_form(&get_defaults);

use

Code:
if ( $in{'another'} ) {
&html_record_form(%in);
}
else {
&html_record_form(&get_defaults);
}

This works pretty good for me. Is this what you want?


------------------
JPD





Quote Reply
Re: Making a "COPY" of a record? In reply to
I just thought of another thing you could try, Tom.

Is your "Category" field in a select list? If so, you could set up your add form to take multiple selections, but just allow single selections in a search. Then you wouldn't have to duplicate your records at all.

Or, you could have fields for each Category -- one for Jazz, one for Classical, one for Rock, etc. The user could then check any of the categories that apply. When others do a search, they could also check more than one category, if they are looking for something that fits into both the Rock and the Jazz category, for example.

------------------
JPD





Quote Reply
Re: Making a "COPY" of a record? In reply to
JPDeni!

I never expected to come back from vacation to find so much help waiting on me! Man I love this place! The beach was soooo awesome (sunny, tropical, coconuts, white sand...) But talk about withdrawls! I couldn't wait to get back to my computer and see what groovy things were going on here!

And I can't wait to go try the mod out! It looks like exactly what I'm hoping to do. I'll let you know for sure how it goes....

Thanks!

Quote Reply
Re: Making a "COPY" of a record? In reply to
Hey! Cool stuff!

Why not put this in the Resource centre... very useful...



------------------
Ben

-------------------------
http:/www.t-e.co.uk