Storing Data Instance
  • 24 Aug 2021
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Storing Data Instance

  • Dark
    Light

Article summary

Storing data instance

Closing the resultset

This is an instruction in how to close a result. 

 

The usual flow in a rule is something like this;

  • Define a statement.
  • Execute the statement get a result back.
  • Handle the result 
  • Close the result set. This will tell the DB that this pointer can be freed and tell the system that the connection can be reused.

Why:

            Closing the result will:

  • Tell the DB that the pointer can be freed.
  • Tell the System that the connection can be reused.
  • Tell the System that a prepared statement handle can be reused.

From now on it will be considered bad implementation not to close the result. 

How:

            A select statement looks something like this.

            SqlResult result = selectStatement.execute();

      …//handle content

      result.close();

 

      A Insert Update Delete statement looks something like this if we don’t use the result to se if it was successful. 

      SqlResult result = statement.execute();

      If (result.hasException()) {

            //handle the exception

      }

result.close; 

 

Open data instance for operations

This is an instruction in how to manage simple data instances within a complex one, that is not available for operations. If no fields from a simple data instance within a complex one are put into a portlet, the instance is not opened for operations when the complex data instance is set in update or create mode. This instruction guides you how to manage this.

 

 An example of how this can be managed when activating two simple models in a complex one:

 

// Open simple instance for operations

di.internalInsert("DMDeliveryPickListPackageBarCodeRead34", 0);

di.internalInsert("DMDeliveryPickListPackageBarCodeRead35", 0);

 

// Set instances in mode create

di.getSegment("DMDeliveryPickListPackageBarCodeRead34").setAttribute("mode", "_model_create");

di.getSegment("DMDeliveryPickListPackageBarCodeRead35").setAttribute("mode", "_model_create");

 

// Control session to manage instances

List models = dialogWorkspace.getSubmittedDataModels();

models.add("DMDeliveryPickListPackageBarCodeRead34");

models.add("DMDeliveryPickListPackageBarCodeRead35");

 

                         

The first statement creates the simple data instance in the complex instance. The second sets the mode to _model_create, so it will be managed further in the rule engine as an add to the data source. The third example adds the instances to the session control, meaning that the simple instances will be acted on by the rule engine.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.