翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
スケジュールされたクエリを実行する
次のコードスニペットを使用して、スケジュールされたクエリを実行できます。
- Java
-
public void executeScheduledQueries(String scheduledQueryArn, Date invocationTime) { System.out.println("Executing Scheduled Query"); try { ExecuteScheduledQueryResult executeScheduledQueryResult = queryClient.executeScheduledQuery(new ExecuteScheduledQueryRequest() .withScheduledQueryArn(scheduledQueryArn) .withInvocationTime(invocationTime) ); } catch (ResourceNotFoundException e) { System.out.println("Scheduled Query doesn't exist"); throw e; } catch (Exception e) { System.out.println("Execution Scheduled Query failed: " + e); throw e; } }
- Java v2
-
public void executeScheduledQuery(String scheduledQueryArn) { System.out.println("Executing Scheduled Query"); try { ExecuteScheduledQueryResponse executeScheduledQueryResult = queryClient.executeScheduledQuery(ExecuteScheduledQueryRequest.builder() .scheduledQueryArn(scheduledQueryArn) .invocationTime(Instant.now()) .build() ); System.out.println("Execute ScheduledQuery response code: " + executeScheduledQueryResult.sdkHttpResponse().statusCode()); } catch (ResourceNotFoundException e) { System.out.println("Scheduled Query doesn't exist"); throw e; } catch (Exception e) { System.out.println("Execution Scheduled Query failed: " + e); throw e; } }
- Go
-
func (timestreamBuilder TimestreamBuilder) ExecuteScheduledQuery(scheduledQueryArn string, invocationTime time.Time) error { executeScheduledQueryInput := ×treamquery.ExecuteScheduledQueryInput{ ScheduledQueryArn: aws.String(scheduledQueryArn), InvocationTime: aws.Time(invocationTime), } executeScheduledQueryOutput, err := timestreamBuilder.QuerySvc.ExecuteScheduledQuery(executeScheduledQueryInput) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case timestreamquery.ErrCodeResourceNotFoundException: fmt.Println(timestreamquery.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Printf("Error: %s", aerr.Error()) } } else { fmt.Printf("Error: %s", err.Error()) } return err } else { fmt.Println("ExecuteScheduledQuery is successful, below is the output:") fmt.Println(executeScheduledQueryOutput.GoString()) return nil } }
- Python
-
def execute_scheduled_query(self, scheduled_query_arn, invocation_time): print("\nExecuting Scheduled Query") try: self.query_client.execute_scheduled_query(ScheduledQueryArn=scheduled_query_arn, InvocationTime=invocation_time) print("Successfully started executing scheduled query") except self.query_client.exceptions.ResourceNotFoundException as err: print("Scheduled Query doesn't exist") raise err except Exception as err: print("Scheduled Query execution failed:", err) raise err
- Node.js
-
次のスニペットは JavaScript V2 スタイルに AWS SDKを使用します。これは、Node.js のサンプルアプリケーションに基づいており、 の LiveAnalytics アプリケーション用の Amazon Timestream サンプルです GitHub
。 async function executeScheduledQuery(scheduledQueryArn, invocationTime) { console.log("Executing Scheduled Query"); var params = { ScheduledQueryArn: scheduledQueryArn, InvocationTime: invocationTime } try { await queryClient.executeScheduledQuery(params).promise(); } catch (err) { console.log("Execute Scheduled Query failed: ", err); throw err; } }
- .NET
-
private async Task ExecuteScheduledQuery(string scheduledQueryArn, DateTime invocationTime) { try { Console.WriteLine("Running Scheduled Query"); await _amazonTimestreamQuery.ExecuteScheduledQueryAsync(new ExecuteScheduledQueryRequest() { ScheduledQueryArn = scheduledQueryArn, InvocationTime = invocationTime }); Console.WriteLine("Successfully started manual run of scheduled query"); } catch (ResourceNotFoundException e) { Console.WriteLine($"Scheduled Query doesn't exist: {e}"); throw; } catch (Exception e) { Console.WriteLine($"Execute Scheduled Query failed: {e}"); throw; } }
スケジュールされたクエリを記述する
スケジュールされたクエリを更新する