get.myview Filter Payload using @whereclause

get.myview can now receive a structured filter payload through the @whereclause parameter.

This allows callers to pass business-readable JSON filters rather than manually constructing SQL WHERE clauses.

Example

EXEC get.myview
    '<mytoken>',
    '<mydatamart> project',
    '<myviewname> meta_codes',
    @whereclause = '{
        "objectseq": [
            {
                "PROJECT_ID": ["D103370", "D104110"]
            }
        ],
        "filters": [
            {
                "attribute": "LIFECYCLE"
            }
        ]
    }';

Payload Structure

The filter payload currently supports two main sections:

{
  "objectseq": [],
  "filters": []
}

objectseq

The objectseq section is used to filter values embedded inside the OBJECT_SEQ JSON structure.

Example OBJECT_SEQ value:

{
  "COMPANY_ID": "1062",
  "PROJECT_ID": "D103370"
}

Example filter:

"objectseq": [
  {
    "PROJECT_ID": ["D103370", "D104110"]
  }
]

This allows filtering where the embedded PROJECT_ID is in the supplied list.

Single values and lists are supported.

{
  "PROJECT_ID": "D103370"
}

is treated as an equality filter.

{
  "PROJECT_ID": ["D103370", "D104110"]
}

is treated as an IN filter.

filters

The filters section is used to filter metadata rows.

Supported properties:

PropertyNotes
metatypeFilters [META_TYPE] where supplied
attributeFilters [ATTRIBUTE]
codevalueFilters [CODE_VALUE] where supplied
itemtypeFilters [ITEM_TYPE] in item views
objectnameFilters [ITEM_TYPE] in core views

Example:

"filters": [
  {
    "metatype": "STATUS",
    "attribute": "LIFECYCLE",
    "codevalue": "Active"
  }
]

Where value is supplied as a single codevalue, it is treated as a LIKE filter.

{
  "attribute": "LIFECYCLE",
  "codevalue": "Active"
}

Where codevalue is supplied as an array, it is treated as an IN filter.

{
  "attribute": "LIFECYCLE",
  "codevalue": ["Active", "Closed"]
}

Where value is omitted, the filter only applies to the selected attribute.

{
  "attribute": "LIFECYCLE"
}

Current Behaviour

The current filter model supports:

  • A single codevalue is interpreted as a single-value filter (like)
  • An array is interpreted as a list filter
  • An omitted codevalue filters by the selected attribute
  • Filtering embedded OBJECT_SEQ keys, such as PROJECT_ID
  • Optional filtering by META_TYPE
  • Optional filtering by CODE_VALUE

This keeps the procedure call focused on business intent while allowing get.myview to construct the required SQL internally.

Leave a Comment