QueryResult

描述

QueryResult 对象可用于访问由 queryJobs 方法返回的作业查询结果。

讨论

可通过索引、迭代器或定义的字段名称访问每个作业和属性。

代码示例

QueryResult 示例

以下脚本运行作业查询并访问查询结果。

import arcpy

#Establish a connection to a Workflow database
conn = arcpy.wmx.Connect(r'c:\test\Workflow.jtc')

#Run a query for jobs being assigned to current user. The query results are sorted by job name.
result = conn.queryJobs("JOB_NAME,ASSIGNED_TO","JTX_JOBS","Job Name,Assigned To", "ASSIGNED_TO = '[SYS:CUR_LOGIN]'", "JOB_NAME")

#To get total number of records being returned which are assigned to current user.
print("There are %s jobs assigned to me" % str(len(result.rows)))


#Access first job's name
print("The first returned job's name is %s" % result.rows[0][0])

#Access field name and alias
f = result.fields[0]
print("The returned first field's name is %s" % f.name) 
print("The returned first field's alias is %s" % f.alias)

在本主题中