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

Home > SQLComputed Code issue

Question
Virat Sharma · Jan 30, 2023

SQLComputed Code issue

Hi All,

I have a below query for which I need help.

I have a persistent class User.Cars.cls. The properties of this class is mapped through Global mapping with global (^CAR(Date,CarSerialno,Seq)).

Property CarNumber as %String (TRUNCATE=1) [SqlFieldName= CAR_Number];

Mapping of 5th Piece of ^CAR global to CarNumber property.

For e.g.^CAR(Date,CarSerialno,Seq)=1^2^3^4^BMW 4567^6^7

To increase the security we have encrypted the database. 5th Piece is also encrypted in global (New value after encryption: 'ASAD=4367' through some tool technique).

Now I want to decrypt this value in below section of property CarNumber (SqlComputed code I need to use). But when I put the below code, I am not getting the  any value. Does this not work when we use a SQL storage mapping ? or what can be issue. I also tried "Transient" keyword as well but still not working

Property CarNumber as %String (TRUNCATE=1) [ SqlComputeCode= {

Set CARNUM={CAR_Number}

If Clear Set {CAR_Number}=$$Decrypt(CARNUM)

Else  Set {CAR_Number}=CARNUM

},SqlComputed,SqlFieldName= CAR_Number];

#SQL #Caché
Product version: Caché 2014.1

Source URL:https://community.intersystems.com/post/sqlcomputed-code-issue