Package org.labkey.remoteapi.query
Class SqlExecuteCommand
java.lang.Object
org.labkey.remoteapi.Command<ResponseType,org.apache.hc.client5.http.classic.methods.HttpPost>
- All Implemented Interfaces:
HasRequiredVersion
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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.labkey.remoteapi.Command
Command.CommonParameters, Command.Response
-
Field Summary
Fields inherited from class org.labkey.remoteapi.Command
CONTENT_TYPE_JSON
-
Constructor Summary
ConstructorsConstructorDescriptionSqlExecuteCommand
(String schemaName) Constructs an ExecuteSqlCommand, initialized with a schema name.SqlExecuteCommand
(String schemaName, String sql) Constructs an ExecuteSqlCommand, initialized with a schema name and SQL query. -
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONObject
Returns the JSON object to post or null for no JSON.Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.getSql()
Returns the current SQL query.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.void
setSchemaName
(String schemaName) Sets the current schema name.void
Sets the SQL query to execute.Methods inherited from class org.labkey.remoteapi.PostCommand
createRequest
Methods inherited from class org.labkey.remoteapi.Command
_execute, createParameterMap, createResponse, execute, getActionName, getControllerName, getHttpRequest, getParameters, getParamValueAsString, getRequiredVersion, getTimeout, setRequiredVersion, setTimeout
-
Constructor Details
-
SqlExecuteCommand
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
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
-
setSchemaName
Sets the current schema name.- Parameters:
schemaName
- The new schema name to query.
-
getSql
Returns the current SQL query.- Returns:
- The current SQL query.
-
setSql
Sets the SQL query to execute.- Parameters:
sql
- The new SQL query.
-
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
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
-
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 classPostCommand<CommandResponse>
- Returns:
- The JSON object to post.
-