-
Hello How can one check if SQL statement fails? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
$QueryId = Send-RSDStatement ... if ($sqlResp.Status.Value -eq 'FINISHED') { "SQL execution OK" | Tee-Object -FilePath $logFile -Append } |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
$QueryId = Send-RSDStatement ...
Start-Sleep -Seconds 1
[Amazon.RedshiftDataAPIService.Model.DescribeStatementResponse]$sqlResp = Get-RSDStatement -Id $QueryId ...
while ($sqlResp.Status.Value -notin ('ABORTED', 'FAILED', 'FINISHED'))
{
$sqlResp.Status.Value
Start-Sleep -Seconds 1
$sqlResp = Get-RSDStatement -Id $QueryId -AccessKey $Env:AWS_ACCESS_KEY_ID -SecretKey $Env:AWS_SECRET_ACCESS_KEY -SessionToken $Env:AWS_SESSION_TOKEN
}
if ($sqlResp.Status.Value -eq 'FINISHED') { "SQL execution OK" | Tee-Object -FilePath $logFile -Append }
else {( "SQL execution status is " + $sqlResp.Status.Value) | Tee-Object -FilePath $logFile -Append
$sqlResp.Error | Tee-Object -FilePath $logFile -Append
Wri…