Class SqlExecuteCommand

java.lang.Object
org.labkey.remoteapi.Command<ResponseType,org.apache.hc.client5.http.classic.methods.HttpPost>
org.labkey.remoteapi.PostCommand<CommandResponse>
org.labkey.remoteapi.query.SqlExecuteCommand
All Implemented Interfaces:
HasRequiredVersion

public class SqlExecuteCommand extends PostCommand<CommandResponse>
Command for executing arbitrary LabKey SQL.

LabKey SQL is variant of standard SQL that supports most of the SELECT-related operations. For more information on LabKey SQL, see the following page:

https://www.labkey.org/Documentation/wiki-page.view?name=labkeySql

Uses stream-lined sql-execute.api instead of query-executesql.api

  • Constructor Details

    • SqlExecuteCommand

      public SqlExecuteCommand(String schemaName)
      Constructs an ExecuteSqlCommand, initialized with a schema name.

      When using this constructor, you must call the setSql(String) method before executing the command.

      Parameters:
      schemaName - The schema name to query.
    • SqlExecuteCommand

      public SqlExecuteCommand(String schemaName, String sql)
      Constructs an ExecuteSqlCommand, initialized with a schema name and SQL query.
      Parameters:
      schemaName - The schema name ot query.
      sql - The SQL query.
  • Method Details

    • getSchemaName

      public String getSchemaName()
    • setSchemaName

      public void setSchemaName(String schemaName)
      Sets the current schema name.
      Parameters:
      schemaName - The new schema name to query.
    • getSql

      public String getSql()
      Returns the current SQL query.
      Returns:
      The current SQL query.
    • setSql

      public void setSql(String sql)
      Sets the SQL query to execute.
      Parameters:
      sql - The new SQL query.
    • getQueryParameters

      public Map<String,Object> getQueryParameters()
      Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.
      Returns:
      map of query parameters for the SQL references
    • setQueryParameters

      public void setQueryParameters(Map<String,String> parameters)
      Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.
      Parameters:
      parameters - a map of the named parameters to use in the underlying parameterized queries
    • getLineSeparator

      public String getLineSeparator()
    • getFieldSeparator

      public String getFieldSeparator()
    • getJsonObject

      public org.json.JSONObject getJsonObject()
      Description copied from class: PostCommand
      Returns the JSON object to post or null for no JSON. Override this method to provide parameters as JSON.
      Overrides:
      getJsonObject in class PostCommand<CommandResponse>
      Returns:
      The JSON object to post.