From OpenSCADAWiki
Jump to: navigation, search

The OpenSCADA interface for servicing requests to the database is represented by objects and virtual call functions from the OpenSCADA core:

  • TTypeBD->TModule — the root module object of the "DB" subsystem:
  • string features( ); — keyword list of features supported by the DB.
  • int lsPr( ); — the DB priority base [0...9] in the generic storages list.
  • TBD *openBD( const string &id ); — is called when a new DB object is opened or created by this module with the identifier id.
  • TBD — the database object:
  • void enable( ); — enabling the DB.
  • void disable( ); — disabling the DB.
  • void allowList( vector<string> &list ) const; — requesting the table list in the DB.
  • void sqlReq( const string &req, vector< vector<string> > *tbl = NULL, char intoTrans = EVAL_BOOL ); — processing the SQL-query req to the DB and receiving the result in the form of the tbl table, if the selection request and the pointer are non-zero. When intoTrans is set to "true", a transaction must be open for the request, and closed to "false". This function should be implemented for DBMSs that support SQL-queries.
  • void transCloseCheck( ); — the periodically called function to check the transactions and closing the old or contain many requests ones.
  • TTable *openTable( const string &name, bool create ); — called when you open or create a new table object.
  • TTable — the table object in the database:
  • void fieldStruct( TConfig &cfg ); — getting the current structure of the table in the object cfg.
  • bool fieldSeek( int row, TConfig &cfg, const string &cacheKey = "" ); — sequential scanning of table entries by incrementing row at the object cfg and returning "false" after completion, with addressing by active keyUse() key fields. The cache key cacheKey is specified to prefetch the full response to the cache, extracting the following records from there.
  • void fieldGet( TConfig &cfg ); — request of the record specified in the "cfg" object with addressing by key fields.
  • void fieldSet( TConfig &cfg ); — transfer of the record specified in the "cfg" object with addressing by key fields.
  • void fieldDel( TConfig &cfg ); — deletion of the specified record by the key fields of the "cfg" object.
Specific for SQL Data Bases
  • void fieldFix( TConfig &cfg, const string &langLs = "" ); — correction of DB table structure to cfg and for translation languages langLs, usually after a failed transfer.
  • string getSQLVal( TCfg &cf, uint8_t RqFlg = 0 ); — return a SQL-specific wrapped cf value for the ReqFlg flags of the RqFlg call.
  • void setSQLVal( TCfg &cf, const string &vl, bool tr = false ); — parsing the SQL value vl to translate tr and with writing to cf.