Written by

Question Güvenal · Oct 22, 2019

How to call a class query from .NET client application

Hello!
There is a class query “MemberStatusList” in the SYS.Mirror class that I would like to call from a .NET client application. 
I know that means that there is also a generated class method called MemberStatusListFunc. 
What is the best way if any exist to call them from a .NET application?
Just see if anything responded I tried using something like

IRIS iris = IRIS.CreateIRIS(conn);
var returnValue = iris.ClassMethodString("%SYSTEM.Mirror", "MemberStatusList", "NAMEOFTHEMIRROR")
---
That executes the method and returns the reference as a string to a %SQL.ClassQueryResultSet.
Obviously I would like to have a recordset of some sort to itterate so that call will not work for me.
I looked at using IRISCommand but I cannot figure out how to call the class query.
Is this doable or should I look for another solution?

(the cache database is in a Healthshare HealthConnect 2019.1 installation)


Best regards,
Magnus

Comments

Kevin Chan · Oct 22, 2019

Hello Magnus,

I recommend  that you use a SQL CALL instead of IRIS Native for .Net.

The following CALL query should work: CALL SYS.Mirror_MemberStatusList('NAMEOFTHEMIRROR') and this is no different than using a stored procedure (because MemberStatusList is a class query).

If you do not have a connection to %SYS where SYS.Mirror exists , but the user for your existing connection does have privileges to access %SYS, you can write a wrapper stored procedure something similar to:

CREATE PROCEDURE MirrorMemberStatusList(IN MirrorName %String) RESULT SETS LANGUAGE OBJECTSCRIPT
{
:#Include %occResultSet
    new $NAMESPACE
    set $NAMESPACE="%SYS"
    $$$ResultSet("CALL Sys.Mirror.MemberStatusList('" _ MirrorName _ ')")
}
0
Güvenal  Oct 22, 2019 to Kevin Chan

Hello Kevin!
That was an excellent, elegant and simple solution to my problem.
Thank you very much for your time and effort.
Best regards,
Magnus

0
Güvenal  Oct 22, 2019 to Kevin Chan

Hello again Kevin!
I cannot find a way to promote your "Comment" to an "Answer".
But if you submit it as an answer I will be happy to accept it as the answer to my question yes

Best regards,
Magnus

0
Eduard Lebedyuk  Oct 22, 2019 to Güvenal


Converted original comment to an answer.
 

0