Package oracle.nosql.driver.ops

# Class PrepareRequest

java.lang.Object
oracle.nosql.driver.ops.Request
oracle.nosql.driver.ops.PrepareRequest

public class PrepareRequest extends Request
A request that encapsulates a query prepare call. Query preparation allows queries to be compiled (prepared) and reused, saving time and resources. Use of prepared queries vs direct execution of query strings is highly recommended.

Prepared queries are implemented as `PreparedStatement` which supports bind variables in queries which can be used to more easily reuse a query by parameterization.

See Also:
  - `NoSQLHandle.prepare(oracle.nosql.driver.ops.PrepareRequest)`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PrepareRequest()`
  Default constructor for PrepareRequest

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `getQueryPlan()`
  Returns whether the string value of the query execution plan should be included in the `PrepareResult`.
  `boolean`
  `getQuerySchema()`
  Returns whether the JSON value of the query result schema should be included in the `PrepareResult`.
  `String`
  `getStatement()`
  Returns the query statement
  `int`
  `getTimeout()`
  Returns the timeout to use for the operation, in milliseconds.
  `String`
  `getTypeName()`
  Returns the type name of the request.
  `PrepareRequest`
  `setCompartment(String compartment)`
  Cloud service only.
  `PrepareRequest`
  `setGetQueryPlan(boolean v)`
  Sets whether the string value of the query execution plan should be included in the `PrepareResult`.
  `PrepareRequest`
  `setGetQuerySchema(boolean v)`
  Sets whether the JSON value of the query result schema for the query should be included in the `PrepareResult`.
  `PrepareRequest`
  `setNamespace(String namespace)`
  Sets the optional namespace.
  `PrepareRequest`
  `setStatement(String statement)`
  Sets the query statement.
  `PrepareRequest`
  `setTableName(String tableName)`
  Sets the table name for a query operation.
  `PrepareRequest`
  `setTimeout(int timeoutMs)`
  Sets the request timeout value, in milliseconds.

  ### Methods inherited from class oracle.nosql.driver.ops.Request

  `getCompartment, getNamespace, getRateLimitDelayedMs, getReadRateLimiter, getRetryStats, getTableName, getWriteRateLimiter, setReadRateLimiter, setWriteRateLimiter`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PrepareRequest

    public PrepareRequest()
    Default constructor for PrepareRequest

- ## Method Details

  - ### setCompartment

    public PrepareRequest setCompartment(String compartment)
    Cloud service only.

    Sets the name or id of a compartment to be used for this operation.

    The compartment may be specified as either a name (or path for nested compartments) or as an id (OCID). A name (vs id) can only be used when authenticated using a specific user identity. It is not available if authenticated as an Instance Principal which can be done when calling the service from a compute instance in the Oracle Cloud Infrastructure. See `SignatureProvider.createWithInstancePrincipal()`

    Parameters:
      `compartment` - the name or id. If using a nested compartment, specify the full compartment path `compartmentA.compartmentB`, but exclude the name of the root compartment (tenant).
    Returns:
      this

  - ### getStatement

    public String getStatement()
    Returns the query statement
    Returns:
      the statement, or null if it has not been set

  - ### setStatement

    public PrepareRequest setStatement(String statement)
    Sets the query statement.
    Parameters:
      `statement` - the query statement
    Returns:
      this

  - ### setTimeout

    public PrepareRequest setTimeout(int timeoutMs)
    Sets the request timeout value, in milliseconds. This overrides any default value set with `NoSQLHandleConfig.setRequestTimeout(int)`. The value must be positive.
    Parameters:
      `timeoutMs` - the timeout value, in milliseconds
    Returns:
      this
    Throws:
      `IllegalArgumentException` - if the timeout value is less than or equal to 0

  - ### setNamespace

    public PrepareRequest setNamespace(String namespace)
    Sets the optional namespace. On-premises only. This overrides any default value set with `NoSQLHandleConfig.setDefaultNamespace(java.lang.String)`. Note: if a namespace is specified in the table name in the SQL statement (using the namespace:tablename format), that value will override this setting.
    Parameters:
      `namespace` - the namespace to use for the operation
    Returns:
      this
    Since:
      5.4.10

  - ### setGetQueryPlan

    public PrepareRequest setGetQueryPlan(boolean v)
    Sets whether the string value of the query execution plan should be included in the `PrepareResult`.
    Parameters:
      `v` - true to include the query plan
    Returns:
      this

  - ### getQueryPlan

    public boolean getQueryPlan()
    Returns whether the string value of the query execution plan should be included in the `PrepareResult`.
    Returns:
      the value

  - ### setGetQuerySchema

    public PrepareRequest setGetQuerySchema(boolean v)
    Sets whether the JSON value of the query result schema for the query should be included in the `PrepareResult`.
    Parameters:
      `v` - true to include the query schema
    Returns:
      this
    Since:
      5.4

  - ### getQuerySchema

    public boolean getQuerySchema()
    Returns whether the JSON value of the query result schema should be included in the `PrepareResult`.
    Returns:
      the value
    Since:
      5.4

  - ### getTimeout

    public int getTimeout()
    Returns the timeout to use for the operation, in milliseconds. A value of 0 indicates that the timeout has not been set.
    Returns:
      the value

  - ### setTableName

    public PrepareRequest setTableName(String tableName)
    Sets the table name for a query operation. This is used by rate limiting logic to manage internal rate limiters.
    Parameters:
      `tableName` - the name (or OCID) of the table
    Returns:
      this

  - ### getTypeName

    public String getTypeName()
    Description copied from class: `Request`
    Returns the type name of the request. This is used for stats.
    Specified by:
      `getTypeName` in class `Request`
    Returns:
      the type name of the request