Loading...
Searching...
No Matches
validatefilter.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Validates a filter clause before it gets hashified, returns the RK
4 @details Used to generate a FILTER_RK from an input query dataset.
5 Raw values are stored in dc.mpe_filtersource and the meta values are stored
6 in dc.mpe_filteranytable
7
8 <h4> Service Inputs </h4>
9 <h5> IWANT </h5>
10 |FILTER_TABLE:$41.|
11 |---|
12 |DC258467.MPE_X_TEST|
13
14 <h5> FILTERQUERY </h5>
15 |GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
16 |---|---|---|---|---|---|
17 |AND|AND|1|SOME_BESTNUM|>|1|
18 |AND|AND|1|SOME_TIME|=|77333|
19
20 <h4> Service Outputs </h4>
21
22 <h5> result </h5>
23 @li FILTER_HASH
24 @li FILTER_RK
25 @li FILTER_TABLE
26
27 <h4> SAS Macros </h4>
28 @li dc_assignlib.sas
29 @li mp_abort.sas
30 @li mp_filterstore.sas
31 @li mpe_validatecol.sas
32 @li removecolsfromwork.sas
33
34 @version 9.2
35 @author 4GL Apps Ltd
36 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
37 and may not be re-distributed or re-sold without the express permission of
38 4GL Apps Ltd.
39
40**/
41
42%mpeinit()
43
44/**
45 * filter_table is a request input that flows into executable positions
46 * (mp_filterstore libds=, which interpolates it into SQL). It is read
47 * from the IWANT table in a data step (never re-resolved) and validated
48 * before use - mf_getvalue would re-resolve any macro content in the
49 * value before this code ran. A format catalog is referenced as
50 * LIBREF.CATALOGNAME-FC, so that form is accepted too.
51 */
52%let ds=;
53%let is_libds=0;
54data _null_;
55 length _ds $64;
56 set work.iwant;
57 _ds=filter_table;
58 %mpe_validatecol(_ds,LIBDS,is_libds)
59 if is_libds=0 then putlog 'ERR' 'OR: Invalid filter_table:' _ds;
60 call symputx('is_libds',is_libds,'l');
61 if is_libds=1 then call symputx('ds',upcase(_ds),'l');
62 stop;
63run;
64
65%mp_abort(iftrue= (&is_libds ne 1)
66 ,mac=&_program..sas
67 ,msg=%str(Invalid filter_table)
68)
69
70%dc_assignlib(WRITE,%scan(&ds,1,.))
71
72%mp_filterstore(
73 libds=&ds,
74 queryds=work.filterquery,
75 filter_summary=&dc_libref..mpe_filteranytable,
76 filter_detail=&dc_libref..mpe_filtersource,
77 lock_table=&dc_libref..mpe_lockanytable,
78 maxkeytable=&dc_libref..mpe_maxkeyvalues,
79 outresult=work.result,
80 outquery=work.query, /* not used */
81 mdebug=1
82)
83
84%removecolsfromwork(___TMP___MD5)
85
86proc sql;
87alter table work.result drop PROCESSED_DTTM;
88
89%webout(OPEN)
90%webout(OBJ,result)
91%webout(CLOSE)
92
93%mpeterm()