Published on InterSystems Developer Community (https://community.intersystems.com)

Home > SQL condition in SELECT query

Question
Eduard Lebedyuk · Sep 8, 2019

SQL condition in SELECT query

I'm writing "Finder"-like dialog and need to get list of BPL classes.

The query is dependent on current "path" - it outputs all BPLs in the current path (if any) and all sub-packages which contains BPLs.

So far I have this query:

Query getBPL(path, needPlus = {(path'="")}) As %SQLQuery
{
SELECT DISTINCT $PIECE(Name, '.', 1, $LENGTH(:path, '.') + :needPlus) Name
FROM %Dictionary.ClassDefinitionQuery_SubclassOf('Ens.BusinessProcessBPL')
WHERE Name %STARTSWITH :path
}

My problem is, if I'm not in "root" path I need to add additional dot level, but in root path I only need to add one.

Currently I'm doing it with needPlus  autocalculated parameter, but is there a way to remove it?

#Business Process (BPL) #Ensemble

Source URL:https://community.intersystems.com/post/sql-condition-select-query