-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryDefinition.amp
More file actions
60 lines (51 loc) · 2.79 KB
/
QueryDefinition.amp
File metadata and controls
60 lines (51 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%%[
/* Initialize the RetrieveRequest object to fetch QueryDefinition details */
SET @queryRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@queryRequest, "ObjectType", "QueryDefinition")
AddObjectArrayItem(@queryRequest, "Properties", "CategoryID")
AddObjectArrayItem(@queryRequest, "Properties", "CustomerKey")
AddObjectArrayItem(@queryRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@queryRequest, "Properties", "Status")
AddObjectArrayItem(@queryRequest, "Properties", "QueryText")
AddObjectArrayItem(@queryRequest, "Properties", "Name")
AddObjectArrayItem(@queryRequest, "Properties", "TargetType")
AddObjectArrayItem(@queryRequest, "Properties", "TargetUpdateType")
/* Set up and configure the filter to locate the QueryDefinition using TargetUpdateType */
SET @queryFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@queryFilter, "Property", "TargetUpdateType") /* Filtering by TargetUpdateType */
SetObjectProperty(@queryFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@queryFilter, "Value", "Overwrite") /* Replace with the actual TargetUpdateType filter value */
SetObjectProperty(@queryRequest, "Filter", @queryFilter)
/* Execute the RetrieveRequest to fetch QueryDefinition details */
SET @queryResult = InvokeRetrieve(@queryRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@queryResult) > 0 THEN
/* Loop through the retrieved QueryDefinition records */
FOR @recordIndex = 1 TO RowCount(@queryResult) DO
SET @queryData = Row(@queryResult, @recordIndex)
SET @categoryID = Field(@queryData, "CategoryID")
SET @customerKey = Field(@queryData, "CustomerKey")
SET @createdDate = Field(@queryData, "CreatedDate")
SET @status = Field(@queryData, "Status")
SET @queryText = Field(@queryData, "QueryText")
SET @name = Field(@queryData, "Name")
SET @targetType = Field(@queryData, "TargetType")
SET @targetUpdateType = Field(@queryData, "TargetUpdateType")
/* Output the QueryDefinition details */
OutputLine(Concat("Category ID: ", @categoryID))
OutputLine(Concat("CustomerKey: ", @customerKey))
OutputLine(Concat("Created Date: ", @createdDate))
OutputLine(Concat("Status: ", @status))
OutputLine(Concat("Query Text: ", @queryText))
OutputLine(Concat("Name: ", @name))
OutputLine(Concat("Target Type: ", @targetType))
OutputLine(Concat("Target Update Type: ", @targetUpdateType))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No QueryDefinition records found with the specified filter.")
ENDIF
]%%