Class QueryRpcInstance

java.lang.Object
com.inductiveautomation.ignition.client.rpc.QueryRpcInstance

public class QueryRpcInstance extends Object
  • Field Details

  • Constructor Details

    • QueryRpcInstance

      public QueryRpcInstance()
  • Method Details

    • query

      public Dataset query(@Nonnull String query, @Nonnull String datasourceName) throws Exception
      Parameters:
      query - The query to execute.
      datasourceName - The datasource to run against.
      Returns:
      The dataset returned by the query.
      Throws:
      Exception - If an error occurs while executing the query, typically this will be a timeout.
    • query

      public Dataset query(@Nonnull String query, @Nonnull String datasourceName, @Nullable Integer limit) throws Exception
      Parameters:
      query - The query to execute.
      datasourceName - The datasource to run against.
      limit - The maximum number of rows to return. If <=0, all rows will be returned.
      Returns:
      The dataset returned by the query.
      Throws:
      Exception - If an error occurs while executing the query, typically this will be a timeout.
    • query

      public Dataset query(@Nonnull String query, @Nonnull String datasourceName, @Nullable Integer limit, @Nullable String transactionId) throws Exception
      Parameters:
      query - The query to execute.
      datasourceName - The datasource to run against.
      limit - The maximum number of rows to return. If <=0, all rows will be returned.
      transactionId - The transaction ID to run against, if any.
      Returns:
      The dataset returned by the query.
      Throws:
      Exception - If an error occurs while executing the query, typically this will be a timeout.
    • prepQuery

      public Dataset prepQuery(@Nonnull String query, @Nonnull String datasourceName, @Nullable Object[] params, @Nullable Integer limit, @Nullable String transactionId) throws Exception
      Parameters:
      query - The query to execute.
      datasourceName - The datasource to run against.*
      params - An array of parameters. If this is non-null and non-empty, the query will be executed as a prepared statement.
      limit - The maximum number of rows to return. If <=0, all rows will be returned.
      transactionId - The transaction ID to run against, if any.
      Returns:
      The dataset returned by the query.
      Throws:
      Exception - If an error occurs while executing the query, typically this will be a timeout.
    • update

      public Dataset update(@Nonnull String query, @Nonnull String datasourceName, @Nullable String transactionId, boolean skipAudit, boolean getKey) throws Exception
      Update queries will return a dataset with a single row and a single column, which will contain the number of rows affected by the query or the generated key.

      Set the getKey parameter to true to return the generated key (this is not supported by all databases) otherwise the number of rows affected will be returned.
      Parameters:
      query - The query to execute.
      datasourceName - The datasource to run against.
      transactionId - The transaction ID to run against, if any.
      skipAudit - Whether to skip auditing the query.
      getKey - Whether to return the generated key.
      Throws:
      Exception
    • prepUpdate

      public Dataset prepUpdate(@Nonnull String query, @Nonnull String datasourceName, @Nullable Object[] params, @Nullable String transactionId, boolean skipAudit, boolean getKey) throws Exception
      Update queries will return a dataset with a single row and a single column, which will contain the number of rows affected by the query or the generated key.

      Set the getKey parameter to true to return the generated key (this is not supported by all databases) otherwise the number of rows affected will be returned.
      Parameters:
      query - The query to execute.
      datasourceName - The datasource to run against.
      params - An array of parameters. If this is non-null and non-empty, the query will be executed as a prepared statement.
      transactionId - The transaction ID to run against, if any.
      skipAudit - Whether to skip auditing the query.
      getKey - Whether to return the generated key.
      Returns:
      The dataset returned by the query.
      Throws:
      Exception - If an error occurs while executing the query, typically this will be a timeout.
    • runQuery

      public Dataset runQuery(String query, String datasource, String txId, Object[] params) throws GatewayException
      Parameters:
      query - The query to execute.
      datasource - The datasource to run against.
      txId - The transaction ID to run against, if any.
      params - An array of parameters. If this is non-null and non-empty, the query will be executed as a prepared statement.
      Returns:
      The dataset returned by the query.
      Throws:
      GatewayException - If an error occurs while executing the query.
    • getUpdateQueryMetric

      public StatMetric getUpdateQueryMetric()
    • getSelectQueryMetric

      public StatMetric getSelectQueryMetric()
    • getSelectQueryRowMetric

      public StatMetric getSelectQueryRowMetric()