Storing non-event data
In order to store non-event data in a database, your application needs to use the Connection event’s storeData action. The definition of the storeData action is:
action storeData(
string tableName,
string statementName,
dictionary<string,string> fields,
dictionary<string,string> extraParams) returns integer
The tableName parameter specifies the name of the database table where you want to store the data.
The
statementName parameter specifies the name of a
StoreStatement that references a prepared statement or stored procedure. The
storeStatement is created with the
Connection event's
createStoreStatement action. See
Creating and deleting store events for more information on creating a
storeStatement. If you do not want to specify a prepared statement or stored procedure, the
statementName parameter should be set to
"" (an empty string).
The fields parameter specifies the column values to be stored.
To store an event and provide acknowledgement, implement the storeDataWithAck action and a callback handler. The definition of the storeDataWithAck action is:
action storeDataWithAck(
string tableName,
string statementName,
dictionary<string,string> fields,
string token,
dictionary<string,string> extraParams,
action <Connection, string, string> callback)
In addtion to the parameters used with the storeData action, the storeDataWithAck action includes token and callback parameters. The token parameter specifies a user-defined string to be passed in that will be returned in the callback action. This allows the callback to perform different operations defending on the token value. In this way, a single callback action can perform different operations, eliminating the need to create separate callbacks for each operation. If the token parameter is not needed for the callback, it should be set to "" (an empty string).
The callback parameter specifies the callback action that handles the success or failure of the storeDataWithAck action. The acknowledgement callback string contains any errors reported as well as the returned token, an empty acknowledgement string indicates success.
If you do not have to take additional action each time a row of data is added to a database table, you can avoid the overhead of receiving acknowledgements by using the
storeData action. If your application needs to handle a failure during a call to the
storeData action, it should call the
setStoreErrorCallback action; for more information, see
Handling data storing errors.
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.