Written by

Question Nezla · Aug 17, 2022

Ensemble default packages

Hi Guys,

I've newly joined a new company and have been asked to get the number of classes in their system and was wondering if Ens, EnsLib and EnsPortal are normally a system or default packages that comes with default classes that developers can use or override? 

Thanks

Product version: Caché 2014.1

Comments

Eduard Lebedyuk · Aug 18, 2022

Ens, EnsLib and EnsPortal are system packages, developes can subclass them.

To get class count call something like this:

SELECT 
  count(ID)
FROM %Dictionary.ClassDefinition
WHERE 1=1 AND
      System = 0 AND 
      NOT (Name %STARTSWITH '%' OR 
           Name %STARTSWITH 'Ens.' OR 
           Name %STARTSWITH 'EnsLib.' OR 
           Name %STARTSWITH 'EnsPortal.' OR 
           Name %STARTSWITH 'HS.' OR 
           Name %STARTSWITH 'SchemaMap')

Missing: SQL way to filter out mapped classes.

0
Ben Spead  Aug 18, 2022 to Eduard Lebedyuk

very elegant!

0
Nicholai Mitchko  Aug 18, 2022 to Eduard Lebedyuk

As an aside, does the 1=1 portion of that query matter?

WHERE 1=1 AND
0
Eduard Lebedyuk  Aug 18, 2022 to Nicholai Mitchko

Improves readability as all conditions start on the same indent level.

It's also useful when you have a query with several conditions and you need to debug by changing which conditions you apply. This way you can easily add/remove conditions by commenting lines in/out.

0
Nezla  Aug 18, 2022 to Eduard Lebedyuk

Thank you very much Eduard, but I'm wondering how does 1=1 would improve readability and help in debugging conditions in a query, isn't 1=1 just and extra condition itself ?

Thanks Eduard  

0
Eduard Lebedyuk  Aug 19, 2022 to Nezla

Say you have this query:

SELECT a, b, c
FROM mytable
WHERE d=1 AND e=2

If you want to change fields in SELECT or WHERE, you'll need to rewrite your query by adding or removing it's parts. Source control diff would also show a whole line change.

But if you write it like this:

SELECT 1
  , a 
  , b 
  , c
FROM mytable
WHERE 1=1
      AND d=1 
      AND e=2

You can comment out any field or condition simply by adding --:

SELECT 1
  --, a 
  , b 
  , c
FROM mytable
WHERE 1=1
      --AND d=1 
      AND e=2

when you have a lot of conditions and need to iterate fast, this way of writing queries is much better for debugging and source control since diff is always contianed to the one line you edit.

0