Re: EDS db_replace_key()
> There isn't a db_replace_key() routine, is there? ,
Sure! I used this routine in an app I wrote a while ago. (although
this is from memory, so there may be typos)
~Greg
global procedure db_replace_key( object key1, object key2 )
-- this method is volitle, it will overwrite key2 if it exists
integer rec
object data
-- find the old key
rec = db_find_key( key1 )
if rec< 0 then
-- invalid key
return
end if
-- store the data
data = db_record_data( rec )
-- remove the record
db_delete_record( rec )
-- find the new key
rec = db_find_key( key2 )
if rec < 0 then
-- record does not exist, create it
rec = db_insert( key2, data )
else
-- record does exist, replace data
db_replace_data( rec, data )
end if
end procedure
|
Not Categorized, Please Help
|
|