GetAllRecordsByKey |
Databases | |
| Aptilis 1 | ||
GetAllRecordsByKey(dbDest[], dbSrc[], key, keypos)
GetAllRecordsByKey will extract records from a database (dbSrc)
into a new one (dbDest) according to a criteria specified by you.
This criteria is a field specified by 'key' in the column 'keypos'.
If you want to do a search using wild cards (like '*' or '?')
to do approximative matches, use
GetAllRecordsByNearKey.
You read and write databases from/to files with loadDatabase and saveDatabase respectively.
GetRecordIndexByKey and GetRecordIndexByNearKey are more low-level and only retrieve the index of one record at a time.
Return value:
The number of records(s) retrieved.
Example
sub main
db[0] = makeRecord("chien","dog","1","mammal") $
db[1] = makeRecord("chat","cat","2","mammal") $
db[2] = makeRecord("poisson","fish","3","vertebrate") $
db[3] = makeRecord("escargot","snail","4","invertebrate") $
db[4] = makeRecord("souris","mouse","5","mammal") $
db[5] = makeRecord("perroquet","parrot","6","bird") $
db[6] = makeRecord("dauphin","dolphin","7","mammal") $
db[7] = makeRecord("fleur","flower","8","plant") $
n = GetAllRecordsByKey(newDb[], db[], "mammal", 3)
print("Found: ", n, " records\n")
for i=0 to n-1
getAllFields(fl[], newDb[i]$)
print(fl[1]$, " ", fl[3]$, "\n")
end for
end main
Result:
Found: 4.000000 records dog mammal cat mammal mouse mammal dolphin mammal |
