comparing two recordsets?

D

danielle.m.manning

Can someone help me figure out what is the best way to perform this
task?

I have to detect if there were any changes from one recordset to
another. My recordset consists of a key (guid), and then three
fields. There will probably only be three or four records in each
set, so i'm not going to be dealing with a ton of processing.

For Example:
oRS - recordsetname
oRS("EmpKey") - my guid for the record
oRS("Name") - name of the employee
oRS("Salary") - salary of the employee
oRS("Hours") - hours the employee worked this week

In a language like perl, i would create two hashes, and compare these
hashes by key - but i don't know how to do this in ASP. I only need
to know if they differ in some way - but I don't think just doing a
rowcount is going to suffice.

Thanks for any assistance.
 
B

Bob Barrows [MVP]

Can someone help me figure out what is the best way to perform this
task?

I have to detect if there were any changes from one recordset to
another. My recordset consists of a key (guid), and then three
fields. There will probably only be three or four records in each
set, so i'm not going to be dealing with a ton of processing.

For Example:
oRS - recordsetname
oRS("EmpKey") - my guid for the record
oRS("Name") - name of the employee
oRS("Salary") - salary of the employee
oRS("Hours") - hours the employee worked this week

In a language like perl, i would create two hashes, and compare these
hashes by key - but i don't know how to do this in ASP. I only need
to know if they differ in some way - but I don't think just doing a
rowcount is going to suffice.
Could you provide more details? it could be you are trying to duplicate
functionality that already exists. Is the data in the recordsets from
the same server/database/table?
 
B

Bob Barrows [MVP]

Can someone help me figure out what is the best way to perform this
task?

I have to detect if there were any changes from one recordset to
another. My recordset consists of a key (guid), and then three
fields. There will probably only be three or four records in each
set, so i'm not going to be dealing with a ton of processing.

For Example:
oRS - recordsetname
oRS("EmpKey") - my guid for the record
oRS("Name") - name of the employee
oRS("Salary") - salary of the employee
oRS("Hours") - hours the employee worked this week

In a language like perl, i would create two hashes, and compare these
hashes by key - but i don't know how to do this in ASP. I only need
to know if they differ in some way - but I don't think just doing a
rowcount is going to suffice.
Oh! And what types of changes are you trying to detect? Added/Deleted
records? Modified data in any of the fields?
 
D

danielle.m.manning

Oh! And what types of changes are you trying to detect? Added/Deleted
records? Modified data in any of the fields?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -

- Show quoted text -

Thanks for your assistance -

I am trying to detect any changes - an addition, a deletion, or a
modification in the fields. As far as the data being in the database
- it's not. The functionality as it exists is that for a given key, a
"kill and fill" is done with the records in the database. What I have
done is before the "kill" - put the existing records in a recordset.
Then the kill and fill is performed. But I want to compare the
records as they were in the database before the kill with the new
records in the "fill" to see if a "change record" needs to be
written.

I'm trying to not change too much of the existing functionality in
order to accomplish the determination of a change -

Thanks again.
 
B

Bob Barrows [MVP]

Thanks for your assistance -

I am trying to detect any changes - an addition, a deletion, or a
modification in the fields. As far as the data being in the database
- it's not. The functionality as it exists is that for a given key, a
"kill and fill" is done with the records in the database. What I have
done is before the "kill" - put the existing records in a recordset.
Then the kill and fill is performed. But I want to compare the
records as they were in the database before the kill with the new
records in the "fill" to see if a "change record" needs to be
written.

And what if the data in the database changes while you are doing this
comparison?
I really don't like this approach. Too much reliance on cursors and not
enough on transaction processing. What database are you using? If SQL
Server, then you should definitely be using a trigger to generate your
"change record".
 
D

danielle.m.manning

And what if the data in the database changes while you are doing this
comparison?
I really don't like this approach. Too much reliance on cursors and not
enough on transaction processing. What database are you using? If SQL
Server, then you should definitely be using a trigger to generate your
"change record".





--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -

- Show quoted text -

I don't like the approach either - but I am guaranteed that the data
won't change in the database because it is on a per user basis - so,
unless two people are logged in as the same user -there can't be any
changes underneath.

This is SQL Server. Triggers (for this business) are not desireable
due to their maintainability.

I think i am being too unclear - I am really just looking for syntax
for a looping mechanism. For example -
if I have

key 1
key 2
key 3

in the first set and
key 1
key 2
key 3

in the second set - how can i compare the datas key / value pairs?

As I mentioned - this is something I would do using a foreach & a hash
in perl . I am just not familiar enough with Classic ASPs constructs
to know what is the proper mechanism.
 
M

Mike Brind

I don't like the approach either - but I am guaranteed that the data
won't change in the database because it is on a per user basis - so,
unless two people are logged in as the same user -there can't be any
changes underneath.

This is SQL Server. Triggers (for this business) are not desireable
due to their maintainability.

I think i am being too unclear - I am really just looking for syntax
for a looping mechanism. For example -
if I have

key 1
key 2
key 3

in the first set and
key 1
key 2
key 3

in the second set - how can i compare the datas key / value pairs?

As I mentioned - this is something I would do using a foreach & a hash
in perl . I am just not familiar enough with Classic ASPs constructs
to know what is the proper mechanism.

http://www.w3schools.com/vbscript/vbscript_looping.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top