contents   index   previous   next



SimpleDataset replaceRecord()

syntax:

simpledataset.replaceRecord(record)

where:

record - object whose properties contain the values of the fields of the record to replace the current record with.

 

return:

boolean - value indicating success. In the case that the operation failed, use the getLastErrorCode() and getLastError() methods to determine the reason for the failure.

 

description:

This method replaces the current record in the SimpleDataset with the specified record. The record that the current record will be replaced with will have the field values indicated by the properties of the object passed into addRecord. After inserting a new record, the current record remains unchanged; that is, the current record is the record that replaced the previous current record.

 

see:

#include <smdtset.jsh>, SimpleDataset addRecord(), SimpleDataset deleteRecord()

 

example:

// This function will set the population

// of the first record

// with USA as its country to 100,000

function replace_population(db, table, user,

                            passwd)

{

   var ds = new SimpleDataset(db, table, user,

                              passwd );

 

   // find the entries whose country is USA

   var template;

   template.country = "USA";

   ds.find(template);

 

   // advance to first record in the result set

   var rec = ds.nextRecord();

 

   if( null != rec )

   {

      // set the new population value

      rec.population = 100000;

 

      // replace the record and clean up

      ds.replaceRecord(rec);

   }

   ds.close();

}

 


SimpleDataset cursor()