執行查詢
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如要執行查詢,請傳送 queries.run
要求,並附上 queryId
和執行詳細資料。這項要求會傳回執行中的 Report
資源。
以下說明如何執行查詢並擷取產生的報表資源 ID:
Java
// ID of query to run.
Long queryId = query-id;
// Run the query.
Report report = service.queries().run(queryId, null).execute();
// Print the running report ID.
System.out.printf(
"Report %s generated and running.%n",
report.getKey().getReportId());
Python
# The ID of the existing query.
query_id = query-id
# Run the query.
running_report = (
service.queries().run(queryId=query_id).execute()
)
# Print running report ID.
print(f'Report {running_report["key"]["reportId"]} generated and running.')
PHP
// ID of the query to run.
$queryId = query-id;
// Run the query.
$report = $this->service->queries->run(
$queryId,
new Google_Service_DoubleClickBidManager_RunQueryRequest(),
array());
// Print the running report ID
printf(
'Report %s generated and running.<br>',
$report->getKey()->getReportId());
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eSend a \u003ccode\u003equeries.run\u003c/code\u003e request with the \u003ccode\u003equeryId\u003c/code\u003e and execution details to run a query which will return a running \u003ccode\u003eReport\u003c/code\u003e resource.\u003c/p\u003e\n"],["\u003cp\u003eSchedule \u003ccode\u003eQuery\u003c/code\u003e resources for automatic execution using the \u003ccode\u003eschedule\u003c/code\u003e field during creation, and retrieve reports using \u003ccode\u003equeries.reports.list\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe provided Java, Python, and PHP code snippets demonstrate how to run a query and retrieve the resulting report resource ID.\u003c/p\u003e\n"]]],[],null,["# Run query\n\nTo run a query, send a [`queries.run`](/bid-manager/reference/rest/current/queries/run) request with the\n[`queryId`](/bid-manager/reference/rest/current/queries#Query.FIELDS.query_id) and execution details. This request returns a\nrunning [`Report`](/bid-manager/reference/rest/current/queries.reports#Report) resource.\n| **Tip:** Schedule [`Query`](/bid-manager/reference/rest/current/queries#Query) resources to run automatically using the [`schedule`](/bid-manager/reference/rest/current/queries#Query.FIELDS.schedule) field during creation. Retrieve reports generated by scheduled queries using [`queries.reports.list`](/bid-manager/reference/rest/current/queries/list).\n\nHere's how to run a query and retrieve the resulting report resource ID: \n\n### Java\n\n```java\n// ID of query to run.\nLong queryId = query-id;\n\n// Run the query.\nReport report = service.queries().run(queryId, null).execute();\n\n// Print the running report ID.\nSystem.out.printf(\n \"Report %s generated and running.%n\",\n report.getKey().getReportId());\n```\n\n### Python\n\n```python\n# The ID of the existing query.\nquery_id = query-id\n\n# Run the query.\nrunning_report = (\n service.queries().run(queryId=query_id).execute()\n)\n\n# Print running report ID.\nprint(f'Report {running_report[\"key\"][\"reportId\"]} generated and running.')\n```\n\n### PHP\n\n```php\n// ID of the query to run.\n$queryId = \u003cvar translate=\"no\"\u003equery-id\u003c/var\u003e;\n\n// Run the query.\n$report = $this-\u003eservice-\u003equeries-\u003erun(\n $queryId,\n new Google_Service_DoubleClickBidManager_RunQueryRequest(),\n array());\n\n// Print the running report ID\nprintf(\n 'Report %s generated and running.\u003cbr\u003e',\n $report-\u003egetKey()-\u003egetReportId());\n```"]]