

# GetStatementResult


Fetches the temporarily cached result of an SQL statement in JSON format. The `ExecuteStatement` or `BatchExecuteStatement` operation that ran the SQL statement must have specified `ResultFormat` as `JSON` , or let the format default to JSON. A token is returned to page through the statement results.

For more information about the Amazon Redshift Data API and AWS CLI usage examples, see [Using the Amazon Redshift Data API](https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html) in the *Amazon Redshift Management Guide*. 

## Request Syntax


```
{
   "Id": "string",
   "NextToken": "string"
}
```

## Request Parameters


For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

**Note**  
In the following list, the required parameters are described first.

 ** [Id](#API_GetStatementResult_RequestSyntax) **   <a name="redshiftdata-GetStatementResult-request-Id"></a>
The identifier of the SQL statement whose results are to be fetched. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API. A suffix indicates then number of the SQL statement. For example, `d9b6c0c9-0747-4bf4-b142-e8883122f766:2` has a suffix of `:2` that indicates the second SQL statement of a batch query. This identifier is returned by `BatchExecuteStatment`, `ExecuteStatment`, and `ListStatements`.   
Type: String  
Pattern: `[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}(:\d+)?`   
Required: Yes

 ** [NextToken](#API_GetStatementResult_RequestSyntax) **   <a name="redshiftdata-GetStatementResult-request-NextToken"></a>
A value that indicates the starting point for the next set of response records in a subsequent request. If a value is returned in a response, you can retrieve the next set of records by providing this returned NextToken value in the next NextToken parameter and retrying the command. If the NextToken field is empty, all response records have been retrieved for the request.   
Type: String  
Required: No

## Response Syntax


```
{
   "ColumnMetadata": [ 
      { 
         "columnDefault": "string",
         "isCaseSensitive": boolean,
         "isCurrency": boolean,
         "isSigned": boolean,
         "label": "string",
         "length": number,
         "name": "string",
         "nullable": number,
         "precision": number,
         "scale": number,
         "schemaName": "string",
         "tableName": "string",
         "typeName": "string"
      }
   ],
   "NextToken": "string",
   "Records": [ 
      [ 
         { ... }
      ]
   ],
   "TotalNumRows": number
}
```

## Response Elements


If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [Records](#API_GetStatementResult_ResponseSyntax) **   <a name="redshiftdata-GetStatementResult-response-Records"></a>
The results of the SQL statement in JSON format.  
Type: Array of arrays of [Field](API_Field.md) objects

 ** [ColumnMetadata](#API_GetStatementResult_ResponseSyntax) **   <a name="redshiftdata-GetStatementResult-response-ColumnMetadata"></a>
The properties (metadata) of a column.   
Type: Array of [ColumnMetadata](API_ColumnMetadata.md) objects

 ** [NextToken](#API_GetStatementResult_ResponseSyntax) **   <a name="redshiftdata-GetStatementResult-response-NextToken"></a>
A value that indicates the starting point for the next set of response records in a subsequent request. If a value is returned in a response, you can retrieve the next set of records by providing this returned NextToken value in the next NextToken parameter and retrying the command. If the NextToken field is empty, all response records have been retrieved for the request.   
Type: String

 ** [TotalNumRows](#API_GetStatementResult_ResponseSyntax) **   <a name="redshiftdata-GetStatementResult-response-TotalNumRows"></a>
The total number of rows in the result set returned from a query. You can use this number to estimate the number of calls to the `GetStatementResult` operation needed to page through the results.   
Type: Long

## Errors


For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** InternalServerException **   
The Amazon Redshift Data API operation failed due to invalid input.     
 ** Message **   
The exception message.
HTTP Status Code: 500

 ** ResourceNotFoundException **   
The Amazon Redshift Data API operation failed due to a missing resource.     
 ** Message **   
The exception message.  
 ** ResourceId **   
Resource identifier associated with the exception.
HTTP Status Code: 400

 ** ValidationException **   
The Amazon Redshift Data API operation failed due to invalid input.     
 ** Message **   
The exception message.
HTTP Status Code: 400

## See Also


For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/redshift-data-2019-12-20/GetStatementResult) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/redshift-data-2019-12-20/GetStatementResult) 