Logo Search packages:      
Sourcecode: dballe version File versions

F77_INTEGER_FUNCTION() idba_prendilo ( INTEGER(handle)   ) 

Insert a new item in the database.

This function will fail if the database is open in data readonly mode, and it will refuse to overwrite existing values if the database is open in data add mode.

If the database is open in pseudoana reuse mode, the pseudoana values provided on input will be used to create a pseudoana record if it is missing, but will be ignored if it is already present. If it is open in pseudoana rewrite mode instead, the pseudoana values on input will be used to replace all the existing pseudoana values.

handle Handle to a DBALLE session
The error indicator for the function

Definition at line 1815 of file simple.c.

References dba_error_consistency, DBA_RUN_OR_RETURN, DBA_VAR_X, DBA_VAR_Y, and DBA_VERBOSE_STREAM.

      int ana_id, context_id;
      dba_record_cursor cur;
      dba_var var = NULL;

      if (STATE.perms & PERM_DATA_RO)
            return dba_error_consistency(
                  "idba_prendilo cannot be called with the database open in data readonly mode");

      if (dba_verbose_is_allowed(DBA_VERB_DB_INPUT))
                        "invoking dba_insert_or_replace(%d, <input>, %d, %d).  <input> is:\n",
                        STATE.perms & PERM_DATA_WRITE ? 1 : 0,
                        STATE.perms & PERM_ANA_WRITE ? 1 : 0);
            dba_record_print(STATE.input, DBA_VERBOSE_STREAM);

                        SESSION, STATE.input,
                        STATE.perms & PERM_DATA_WRITE ? 1 : 0,
                        STATE.perms & PERM_ANA_WRITE ? 1 : 0,
                        &ana_id, &context_id));

      /* Set the values in the output */
      DBA_RUN_OR_RETURN(dba_record_key_seti(STATE.output, DBA_KEY_ANA_ID, ana_id));
      DBA_RUN_OR_RETURN(dba_record_key_seti(STATE.output, DBA_KEY_CONTEXT_ID, context_id));

      /* Set context id and variable name on qcinput so that
       * attribute functions will refer to what has been written */
      DBA_RUN_OR_RETURN(dba_record_key_seti(STATE.qcinput, DBA_KEY_CONTEXT_ID, context_id));

      /* If there was only one variable in the input, we can pass it on as a
       * default for attribute handling routines; otherwise we unset to mark
       * the ambiguity */
      if ((cur = dba_record_iterate_first(STATE.input)) != NULL &&
                  dba_record_iterate_next(STATE.input, cur) == NULL)
            var = dba_record_cursor_variable(cur);
      if (var != NULL)
            dba_varcode code = dba_var_code(var);
            char varname[8];
            snprintf(varname, 7, "B%02d%03d", DBA_VAR_X(code), DBA_VAR_Y(code));
            DBA_RUN_OR_RETURN(dba_record_key_setc(STATE.qcinput, DBA_KEY_VAR_RELATED, varname));
            DBA_RUN_OR_RETURN(dba_record_key_unset(STATE.qcinput, DBA_KEY_VAR_RELATED));

      /* Copy the input on the output, so that QC functions can find the data
       * they need */
      return dba_error_ok();

Generated by  Doxygen 1.6.0   Back to index