kognesty Newbie
Joined: 08 Jan 2001 Posts: 8 Location: USA
|
Posted: Thu Mar 28, 2002 7:09 am |
From my personal id database script this is part of an alias that is triggered on a blank line, as apposed to putting the whole mess in the $ trigger, I hope this will help you
#VAR dbCompare %query( ((&Object=@dbItem.Object)&(&Craftsmanship=@dbItem.Craftsmanship)&(&Armor=@dbItem.Armor)&(&Flags=@dbItem.Flags)&(&Affect=@dbItem.Affect)), dbType)
#VAR dbDoesExist 0
#IF (!%null( @dbCompare)) {dbDoesExist=1}
#IF (@dbDoesExist) {#YESNO "This record already exists in the current Database. Are you sure you want to add it?" {#NEW All @dbItem} {No:#NOOP}} {#NEW All @dbItem}
Basically what happens is the database is queryed to see if any entries have the same values, such as an item named the same with the same ac bonus or cost then a check is made to see if any database records where returned. If yes, you are prompted that the record already exists and asked if you wish to add a duplicate, if no the item is added to the database. This can easily be expanded to replace a database record if you wish, but I'll leave that part up to you. |
|