You need to wrap it into a classmethod which is exposed as a stored procedure as in the example below:

Class DC.Utils [ Abstract ]
{

ClassMethod AESBCEncrypt(
pPlainText As %String,
pKey As %String) As %String [ SqlProc ]
{

return $system.Encryption.AESCBCEncrypt(pPlainText, pKey)
}

}

 Once you have done this, you can use something like:

update sample.person (Name) values (DC.Utils_AESBCEncrypt(name,'key'))

You should use Caché security features to prevent unauthorized access to the index global and the code etc. I didn't use a standard hash like SHA-1 or SHA-256 and used a "salted" hash to make it harder to use standard rainbow tables.

I didn't claim that it is 100% safe. As long as you get access to the hashes and the MakeSearchField function there is a potential risk.

There is PERFMON and the Line-By-Line Monitor which you can use to analyze your routines. With PERFMON you can identify the most busy and expensive ROUTINES and you can then analyze a specific routine in detail.

Here are the links to the docs:

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

Hope this helps.

-Michael

Evgeny,

for these purposes I use a calculated measure. The MDX-expression for the measure looks like this:

[Measures].[Amount Sold]/
%MDX("select [Measures].[Amount Sold] on 1 from holefoods")

My complete MDX is:

SELECT {[Measures].[Amount Sold],[MEASURES].[Percentage]} ON 0,NON EMPTY [Channel].[H1].[Channel Name].Members ON 1 FROM [HOLEFOODS]

Hope this helps.

-Michael