PG_LAST_UNLOAD_ID - Amazon Redshift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

PG_LAST_UNLOAD_ID

Returns the query ID of the most recently completed UNLOAD command in the current session. If no UNLOAD commands have been run in the current session, PG_LAST_UNLOAD_ID returns -1.

The value for PG_LAST_UNLOAD_ID is updated when the UNLOAD command begins the load process. If the UNLOAD fails because of invalid load data, the UNLOAD ID is updated, so you can use the UNLOAD ID for further investigation. If the UNLOAD transaction is rolled back, the UNLOAD ID is not updated.

The UNLOAD ID is not updated if the UNLOAD command fails because of an error that occurs before the load process begins, such as a syntax error, access error, invalid credentials, or insufficient privileges.

Syntax

PG_LAST_UNLOAD_ID()

Return type

Returns an integer.

Example

The following query returns the query ID of the latest UNLOAD command in the current session.

select PG_LAST_UNLOAD_ID(); PG_LAST_UNLOAD_ID --------------- 5437 (1 row)