From a8a6cc3b21512369ee065ab71235595b170ca0d4 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Tue, 23 Mar 2021 13:10:50 +0000 Subject: [PATCH 1/2] Update documentation about fallback templates --- docs/guides/03-batch-queries.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/guides/03-batch-queries.md b/docs/guides/03-batch-queries.md index 35d83045..18af285e 100644 --- a/docs/guides/03-batch-queries.md +++ b/docs/guides/03-batch-queries.md @@ -460,15 +460,13 @@ This is helpful when you want to save error messages into a table: curl -X POST -H "Content-Type: application/json" -d '{ "query": { "query": [{ - "query": "UPDATE wrong_table SET price = '$100.00' WHERE company = 'CARTO'" - }], - "onerror": "INSERT INTO errors_log (job_id, error_message, date) VALUES ('<%= job_id %>', '<%= error_message %>', NOW())" + "query": "UPDATE wrong_table SET price = '$100.00' WHERE company = 'CARTO'", + "onerror": "INSERT INTO errors_log (job_id, error_message, date) VALUES ('<%= job_id %>', '<%= error_message %>', NOW())" + }] } }' "https://{username}.carto.com/api/v2/sql/job" ``` -More templates are coming soon. - ### Fetching Job Results In some scenarios, you may need to fetch the output of a job. If that is the case, wrap the query with `SELECT * INTO`, or `CREATE TABLE AS`. The output is stored in a new table in your database. For example, if using the query `SELECT * FROM airports`: From 0787cc8bb5afa4ba1f41ea2d67c4dd8ffb608b18 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Tue, 23 Mar 2021 13:25:38 +0000 Subject: [PATCH 2/2] Specify templates are defined at the query level --- docs/guides/03-batch-queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/03-batch-queries.md b/docs/guides/03-batch-queries.md index 18af285e..f323205a 100644 --- a/docs/guides/03-batch-queries.md +++ b/docs/guides/03-batch-queries.md @@ -449,7 +449,7 @@ If a query of a job fails (and onerror fallbacks for that query and job are defi #### Templates -Batch Queries provide a simple way to get the error message and the job identifier to be used in your fallbacks, by using the following templates: +Batch Queries provide a simple way to get the error message and the job identifier to be used in your fallbacks defined at the query level, by using the following templates: - `<%= error_message %>`: will be replaced by the error message raised by the database. - `<%= job_id %>`: will be replaced by the job identifier that Batch Queries provides.