list Of %String problem
I am trying to initialize a list of %string property to an empty list, and after add eleements.
d ##class(Test.Test).Test("hello") ; works perfectly
d ##class(Test.Test).Test("") ; does not work, the list stays empty
How can I do that. Thank you so much
Class Test.Test Extends %Persistent
{
Property ReviewedBy As list Of %String;
ClassMethod Test(val = "")
{
Set t = ##class(Forerun.Test).%New()
If val'="" Do t.ReviewedBy.Insert(val)
Else Do t.ReviewedBy.Clear() ; does not work also Set t.ReviewedBy = ""
$$$THROWONERROR(tSC, t.%Save())
Set id = t.%Id()
Set user = "me"
&SQL(UPDATE Test.Test
SET ReviewedBy = ReviewedBy||$ListBuild(:user)
WHERE ID=:id
)
If SQLCODE<0 Write "Problem",! Quit
}
Discussion (1)0
Comments
Just add empty string as is:
ClassMethod Test(val = "")
{
Set t = ##class(Forerun.Test).%New()
Do t.ReviewedBy.Insert(val)
$$$THROWONERROR(tSC, t.%Save())
Set id = t.%Id()
Set user = "me"
&SQL(UPDATE Test.Test
SET ReviewedBy = ReviewedBy||$ListBuild(:user)
WHERE ID=:id
)
If SQLCODE<0 Write "Problem",! Quit
}