Example of FindItemsBySQL3 (Python)

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