|
surge321123 Beginner
Joined: 09 Jun 2011 Posts: 14
|
Posted: Sat Jun 18, 2011 7:30 pm
database variables |
I have a database variable that stores the name of items, and the number of items. I figured out how to show the name of the values in the VALUE column using #SHOW %DB(@variablename, "item1") item1 being the name of item in the KEY column. I have been searching the help files but haven't had much luck with this. I need to know how to change values in the KEY column and the Value column I also need to know how to show the values in the KEY column.
I have been experimenting with things like %db(@variablename, "item1") = 20 but it doesn't work
any ideas? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sat Jun 18, 2011 10:10 pm |
%dbkeys(@var)
%dbkey(@var, 1)
There is no way to change the name of a key that i know of, but it is simple enough to assign the key a new value, to delete a key, or assign the value of one key to another.
there is a shorter way to access the value of a given key as well... @var.key
#ADDKEY var {newkey=@var.key}
#DELKEY var key |
|
_________________ Discord: Shalimarwildcat |
|
|
|
surge321123 Beginner
Joined: 09 Jun 2011 Posts: 14
|
Posted: Sun Jun 19, 2011 6:00 pm |
OK I wrote the code and ran into a problem. When I do @ListOfUniques.20 = 5 It sets the value in record 20 to 5... However, when I use this code below, it appends the database and I don't understand why
Quote: |
pattern
our archivists have verified that (%d) (*) {has|have} been seen in recent days.
the value is
$numlist = @ListOfUniques
$triglist = @uniquetrigs
#IF (%ismember(%2, $triglist)) {
$tempuni = %db($triglist, %2)
$numlist.$tempuni = %1
}
ListOfUniques = $numlist
|
The way this code works, there are 2 DB variables. One is a list of all possible syntaxes the trigger above will come up with and the value is the record number that belongs to the accompanying database. The second database is a list of all the items, and the value should be the number of items currently out.
For whatever reason, at the bottom of ListOfUniques, it makes new entries, the KEY is the record number($tempuni) and the value is the number out (%2). Anyone see whats wrong with the code I used?
What is weird is that @ListOfUniques.20 = 5 will set the value to 5 on record number 20... but when I do it with a trigger, it makes a new record at the bottom... |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Jun 20, 2011 12:39 am |
I believe that the problem is that, in the dot syntax, $numlist.$tempuni, $tempuni will never be interpreted as an item number, and will always be interpreted as a key name. Using $numlist.20 will work; using $numlist.$tempuni where $tempuni equals 20 won't work for what you are trying to do. You need to use other methods to assign the value (e.g. #ADDKEY)
In general with database variables, it is much better to use keynames rather than index numbers, because you cannot guarantee that the index number will stay the same. Is there a reason you are using index numbers in your code? You talked about wanting to change the key value earlier. Can you explain in more detail what you are trying to do? |
|
|
|
|
|
|
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
|
|