- Log in to post comments
User bio
404 bio not found
Member since Jun 17, 2021
Posts:
FELIPE has not published any posts yet.
Replies:
The %Statement class doesn't apply to your idea of multiple update executions because the code uses a "sql" variable with its subscripts 1 and 2 as code snippets for concatenation of the full command.
According to your needs, I used the %ResultSet class in the example below and in the "sql" variable assigns a complete update command to each subscriber.
ClassMethod MultipleUpdate() As %Status{ Try { Set sql = 2,tSC = $$$OK Set sql(1) = "UPDATE Cinema.Theater SET TheaterName = 'Theater A',AdultPrice=3 WHERE ID = 10" Set sql(2) = "UPDATE Cinema.Theater SET TheaterName = 'Theater B',AdultPrice=9 WHERE ID = 11"
Set key=$Order(sql(""))
While (key'="")
{
Set tResult = ##class(%ResultSet).%New() Do tResult.Prepare(sql(key)) Set tSC = tResult.Execute()
Set key = $ORDER(sql(key))
}
}
Catch(tException)
{
#DIM tException As %Exception.AbstractException;
Set tSC = tException.AsStatus()
}
Quit tSC}Documentation References:
%SQL.Statement - Intersystems Documentation
%ResultSet - Intersystems Documentation
- Log in to post comments
Hi Rochdi, the command that you looking for is "Do ^%G":
.png)
- Log in to post comments
Certifications & Credly badges:
FELIPE has no Certifications & Credly badges yet.
Followers:
FELIPE has no followers yet.
Following:
FELIPE has not followed anybody yet.
@Kevin McGinn, use the recommendations passed by @Robert Cemper
and you need to pass "*" on Execute() method, sample works code below:
ClassMethod getSecurityUsers() As %Status
{
set rs=##class(%ResultSet).%New()
set rs.ClassName="Security.Users"
set rs.QueryName="Detail"
//Alternatively, you can bind the result set object to a query
//set rs=##class(%ResultSet).%New("Security.Users:Detail")
set sc=rs.Execute("*")
If $$$ISERR(sc) Do DisplayError^%apiOBJ(sc) Quit sc
While rs.%Next()
{
;===== Fields can be used
/*Name:%String,FullName:%String,Comment:%String,Enabled:%String,ExpirationDate:%String,
Roles:%String,GrantedRoles:%String,Namespace:%String,Routine:%String,LastPasswordChangeTime:%String,
LastLoginTime:%String,LastLoginService:%String,LastLoginDevice:%String,LastInvalidLoginTime:%String,LastLoginError:%String,InvalidLoginAttempts:%String,LastInvalidLoginService:%String,LastInvalidLoginDevice:%String,Type:%String,EmailAddress:%String,PhoneNumber:%String,PhoneProvider:%String,AccountNeverExpires:%String,PasswordNeverExpires:%String,AutheEnabled:%String,CreateDateTime:%String,CreateUsername:%String,LastModifiedDateTime:%String,LastModifiedUsername:%String,LastModifiedInfo:%String*/
w rs.Get("Name")_" - "_rs.Get("FullName")_" - "_rs.Get("Enabled")_" - "_rs.Get("LastInvalidLoginDevice")_" - Roles:"_rs.Get("Roles"),!
}
Quit $$$OK
}
Output:
.png)
Version: Ensemble 2017.2.2
I believe the same works for you, I searched this link on documentation (Cache 2017):
Caché & Ensemble 2017.1 - Documentation - Security.Users