运行查询
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需运行查询,请发送包含 queryId
和执行详情的 queries.run
请求。此请求返回一个
正在运行 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());
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):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```"]]