next up previous contents
Next: Deleting data Up: Querying the database Previous: Clearing the database   Contents

Inserting data

Data is inserted using idba_prendilo:

c     Insert a new data in the database
      call idba_setr(handle, "ana_id", 4)
      call idba_setr(handle, "rep_memo", "synop")
      call idba_setd(handle, "lat", 44.500D0)
      call idba_setd(handle, "lon", 11.328D0)
      call idba_setr(handle, "year", 2005)
      call idba_setr(handle, "month", 7)
      call idba_setr(handle, "day", 26)
      ...
      call idba_setr(handle, "B11002", 1.8)
      call idba_prendilo(handle)

This code introduces a new function:

idba_prendilo
inserts a new value in the database. All the information about the parameter to insert is taken from the input previously set by idba_set* functions.

When data of the same kind and with the same characteristics already exists, the behaviour of idba_prendilo is defined by the parameter passed to idba_preparati when creating the handle. See `Starting the work`_ for more informations.

idba_prendilo will work in different ways according to the data opening mode of the database:

read
causes an error, because the data cannot be read.
add
new data can be inserted, but causes an error when trying to insert a value that already exists.
rewrite
new data can be inserted, and existing data is overwritten.

Also, behaviour changes according to the pseudoana opening mode:

"reuse"
when inserting data, if an existing pseudoana record for the data is found, it will be reused.
"rewrite"
when inserting data, if an existing pseudoana record for the data is found, it will be completely overwritten with the parameters in input.

Note that the database cannot be opened in pseudoana read mode when data is add or rewrite.


next up previous contents
Next: Deleting data Up: Querying the database Previous: Clearing the database   Contents
root 2007-06-20