Skip to main content

queries

Creates, updates, deletes, gets or lists a queries resource.

Overview​

Namequeries
TypeResource
Idoci.usage.queries

Fields​

The following fields are returned by SELECT queries:

The saved query.

NameDatatypeDescription
idstringThe query OCID.
compartmentIdstringThe compartment OCID.
queryDefinitionobjectThe common fields for queries.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectqueryId, regionopc-request-idReturns the saved query.<br />
listselectcompartmentId, regionopc-request-id, limit, page, sortBy, sortOrderReturns the saved query list.<br />
createinsertregion, compartmentId, queryDefinitionopc-request-id, opc-retry-tokenReturns the created query.<br />
updateupdatequeryId, region, queryDefinitionopc-request-id, if-matchUpdate a saved query by the OCID.<br />
deletedeletequeryId, regionopc-request-id, if-matchDelete a saved query by the OCID.<br />

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
compartmentIdstringThe compartment ID in which to list resources.
queryIdstringThe query unique OCID.
regionstringOCI region identifier (e.g. us-ashburn-1, ap-sydney-1); resolves from OCI_REGION when not supplied in the query. (default: us-ashburn-1, x-stackQL-envVar: OCI_REGION)
if-matchstringFor optimistic concurrency control. In the PUT or DELETE call for a resource, set the if-match parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted, only if the etag you provide matches the resource's current etag value.
limitintegerThe maximum number of items to return.
opc-request-idstringUnique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
opc-retry-tokenstringA token that uniquely identifies a request so it can be retried in case of a timeout or server error, without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations. For example, if a resource has been deleted and purged from the system, then a retry of the original creation request might be rejected.
pagestringThe page token representing the page at which to start retrieving results. This is usually retrieved from a previous list call.
sortBystringThe field to sort by. If not specified, the default is displayName.
sortOrderstringThe sort order to use, whether 'asc' or 'desc'.

SELECT examples​

Returns the saved query.<br />

SELECT
id,
compartmentId,
queryDefinition
FROM oci.usage.queries
WHERE queryId = '{{ queryId }}' -- required
AND region = '{{ region }}' -- required
AND opc-request-id = '{{ opc-request-id }}'
;

INSERT examples​

Returns the created query.<br />

INSERT INTO oci.usage.queries (
compartmentId,
queryDefinition,
region,
opc-request-id,
opc-retry-token
)
SELECT
'{{ compartmentId }}' /* required */,
'{{ queryDefinition }}' /* required */,
'{{ region }}',
'{{ opc-request-id }}',
'{{ opc-retry-token }}'
RETURNING
id,
compartmentId,
queryDefinition
;

UPDATE examples​

Update a saved query by the OCID.<br />

UPDATE oci.usage.queries
SET
queryDefinition = '{{ queryDefinition }}'
WHERE
queryId = '{{ queryId }}' --required
AND region = '{{ region }}' --required
AND queryDefinition = '{{ queryDefinition }}' --required
AND opc-request-id = '{{ opc-request-id}}'
AND if-match = '{{ if-match}}'
RETURNING
id,
compartmentId,
queryDefinition;

DELETE examples​

Delete a saved query by the OCID.<br />

DELETE FROM oci.usage.queries
WHERE queryId = '{{ queryId }}' --required
AND region = '{{ region }}' --required
AND opc-request-id = '{{ opc-request-id }}'
AND if-match = '{{ if-match }}'
;