Example of FindItemsBySQL3

Example of FindItemsBySQL3
 1# FindItemsBySQL3.txt:
 2# Retrieve database items using specified where clause.
 3
 4ot = impact.gui.output_toolbox
 5
 6db = impact.active_database
 7
 8# Supported fields to sort the results by:
 9# reference: D_NAME
10# customer: D_CUSTOMER: Supported by ipDrawingType.dtProject and ipDrawingType.dtStandard
11# Code: D_CODENUM
12# Created By: D_CREATOR
13# Created Time: D_CRETIME
14# Modified By: D_MODBY
15# Modified Time: D_MODTIME
16# version: D_VERSION
17# description: D_DESCRIPT
18# These are supported by ipDrawingType.dtProject, ipDrawingType.dtTemplate and ipDrawingType.dtStandard.
19
20# Code: S_CODENUM
21# reference: S_NAME
22# description: S_DESCRIPT
23# Created Time: S_CRETIME
24# Created By: S_CREATOR
25# Modified Time: S_MODTIME
26# Modified By: S_MODBY
27# version: S_VERSION
28
29order_field = "D_CUSTOMER"
30
31# The direction of the ordering
32# True = asc
33# False = desc
34order_direction = True
35
36# the type of document
37# ipDrawingType.dtProject
38# ipDrawingType.dtSymbol
39# ipDrawingType.dtTemplate
40# ipDrawingType.dtStandard
41# ipDrawingType.dtStandardPart
42project_type = ipDrawingType.dtProject
43
44# The where clause for the filter
45# insert where clause here
46# can be on any of the columns.
47where_clause = "D_CUSTOMER = 1"
48
49ot.add("------START-----")
50ot.add("FindItemsBySQL3")
51
52items = db.find_items_by_sql3(project_type, where_clause, 100, order_direction, order_field)
53
54ot.add("Total Number of Items: " + str(items.count))
55
56for item in items:
57    ot.add("---ITEM---")
58    ot.add("reference: " + str(item.reference))
59    ot.add("customer : " + str(item.customer.name))
60    ot.add("Code: " + str(item.code))
61    ot.add("Created By: " + str(item.created_by.full_name))
62    ot.add("Created Time: " + str(item.created_date_time))
63    ot.add("Modified By: " + str(item.modified_by.full_name))
64    ot.add("Modified Date: " + str(item.modified_date_time))
65    ot.add("version: " + str(item.version))
66    ot.add("description : " + str(item.description))
67    ot.add("----------")