Skip to main content

Specifying Statement Attributes

Specifying Statement Attributes

When using the SQL adapters, you can specify any driver-dependent statement attributes. To do so:

  • If the connection has not been established, set the StatementAttrs property of the adapter equal to a comma-separated list of attribute-value pairs as follows:

    attribute:value,attribute:value,attribute:value,...
    

    All subsequently created statements will inherit these attributes.

    For example:

    Set ..Adapter.StatementAttrs = "QueryTimeout:10"
    
  • If the connection has already been established, call the SetConnectAttr() method of the adapter. This method takes two arguments (the attribute name and the desired value) and returns a status. For example:

    Set tout= ..Adapter.SetConnectAttr("querytimeout",10)
    

    If a network error is detected, by default, the adapter tries to reconnect and start over. If you are setting connection attributes such as AutoCommit, do the following so that this reconnect/retry logic can occur: test the status returned from SetConnectAttr() and return that status value from the business operation in the case of an error.

Note:

It is your responsibility to ensure that the attributes you use are supported by the ODBC driver for the database to which you are connecting. It is beyond the scope of the InterSystems documentation to attempt to compile any such list.

The most useful places to set statement attributes are as follows:

  • Within a message handler method of a business operation, if you use the SQL outbound adapter.

  • Within the OnInit() method of a business host.

FeedbackOpens in a new tab