|
Dorrin Novice
Joined: 08 Aug 2002 Posts: 41
|
Posted: Sun Dec 08, 2002 3:52 am
Checking database for duplicates before adding |
I have, after much tweaking, managed to write a series of triggers that record information on characters on a MUD I frequent into a database. What I'm trying to do, though, is find a way to avoid having zMUD write duplicate entries.
Bascially, what I've got is a trigger that fires when someone logs in, does a finger (not the social, but checks some basic information on their pfile), then writes information like their name, level, race, etc. We have some players who like to idle off the mud and relog, so it's picking up some people multiple times and I would like to find a way to avoid that. I'm wanting it to check the entire record for that player (all fields under their name) to see if it truly is a duplicate record, then if not, write a new one. I don't necessarily want to overwrite an existing record because there is some information that may change and I'd like to track that.
Any suggestions on where to begin my search for information? I've tried a search of other topics here, but none that I've found have quite matched what I'm trying to do.
Thanks,
Dor |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Dec 08, 2002 3:28 pm |
When you do the finger, grab all of the information from the player and the use the %query function. This function searches through all the records in a given view (you may specify the All view too) and returns a stringlist of the record numbers of all the records that match your criteria. So, let's say that a player logs on and you capture all of the information into the variables: @name, @level, @race. Then, you could use %query like this:
#IF (%numitems(%query(((&Name = @name) & (&Level = @level) & (&Race = @race)), All)) = 0) {Record is unique, add record to the database}
Kjata |
|
|
|
Dorrin Novice
Joined: 08 Aug 2002 Posts: 41
|
Posted: Sun Dec 08, 2002 8:08 pm |
Thank you!!
I tweaked it a bit and am having it query before fingering the person (based of the notification that they've logged in) and then, if it's a unique sign-in, it carries out the rest. It's working great! |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|