Gossamer Forum
Home : Products : DBMan SQL : Discussion :

merging records

Quote Reply
merging records
Hello,

I have a database for electronic journal titles with full text. Many of the same titles are included in several collections, but with different date coverage, etc. I am hoping to merge these titles so that only one record shows up, with all the different date coverages included in this one record, instead of several records with the same title.

Let me show you an example. Take a look at: http://www.indiana.edu/~libej/new.html and do a search for "Science" and check the exact title search box. The search will retrieve six records. I am hoping to merge the six into one, so only one record of the title comes up, without losing the rest of the information. So people can pick and choose the most appropriate link to go.

Is this possible? If so, how?

Thanks a lot.
Jian Liu
Indiana University Libraries
Quote Reply
Re: [jiliu] merging records In reply to
Hi,

Follow the steps below:

- Create a group_data subroutine in Global template:
sub {
my $tags = shift;
my $results = $tags->{results};
my $col = $tags->{column};
($results) or return;
my $last_val;
foreach (@$results) {
if(not defined $last_val or $last_val ne $_->{$col}) {
$_->{group} = 1;
$last_val = $_->{$col};
}
}
}

- Modify your search_results.html like:
.....
<%set column = 'group_field_name'%>
<%group_data%>
<%loop results%>
<%if group%><b><%group_field_name%></b><%endif%>
<%field2%>.....
<%endloop%>
.....

Cheers,

TheStone.

B.

Last edited by:

TheStone: Jan 11, 2002, 5:53 PM
Quote Reply
Re: [TheStone] merging records In reply to
Thanks.

I added the codes in the global template. But I am not sure I can follow the instructions on changing the search_results.html. Currently I have a <%loop reults%> section there. Do you mean that I should add your codes inside there or create a new one? And what should I put as the group_field_name? What I should use for <%field2%>? In other words, I need more help. :-). But this is very desireable feature I want for my database.

Thanks again.


Jian Liu
Indiana University Libraries
Quote Reply
Re: [jiliu] merging records In reply to
Hi,

In this case, the group_field_name should be ''title'' field and <%field2%> ... will be shown up in result page.

Cheers,
TheStone.