Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This API is used to add records to a database object.

Parameters

  1. Database Object:
    (String) Database object name. The name can be qualified with a library/schema. If not qualified the pathlist will be used to resolve the object.
    --or--
    (String) DbDefn file name (with the extension). The file can be qualified with a directory. If not qualified the pathlist will be used to resolve the object.
    --or--
    (Object) DbDefn instance.

  2. Data: (object) - the object that contains the column names and values to be added to the database.
    (Note, this object can contain more, or less, properties then the actual table.  It only uses the matched names.

Exception Handling

An Error instance will be thrown along with these additional properties:

  • sqlstate - The error state.
  • sqlcode - The error code.
  • sqlMessage - The message text.


Code Block
languagejs
titleExample
var record = {
  id: counter,
  firstname: fname,
  lastname: lname,
  dob: null
}

try {

  let result = pjs.data.add("customers", record);
  console.log(result);

} catch(error) {
 console.error(error);
}

...