Hi Ram�n,
I am interested in the way to get the TableName from the Class,
in my case the Table Name is the same as the Class Name (standard storage
method)
but I can not get the Class name also:
##this.Name does not work
in the manual I found:
Set result = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
Do result.Execute()
While (result.Next()) {
Write result.Data("Name"),!
}
and
Set cdef = ##class(%Dictionary.ClassDefinition).%OpenId("Sample.Person")
Write cdef.Name,!
=> ??? isnt "cdef" the same as "##this" ???
brg
werner
> > #6
> > derivation:
> > class MyClass1
>
> I assume class MyClass1 extends MyRootClass...
>
> > {
> > ClassMethod Import (query as %String = "SELECT * FROM XXX WHERE DOCID
> > ...")
> > {
> > // call super with my special query string ???
> > // how is ..%New() handled - I want ##class(MyClass1). ???
> > // how to pass Class for SQL select Count(*) - does it take a
> variable
> > also ???
>
> Last question first - no. If you want to call ##class(MyClass1) instead of
> ..%New(), I'd recommend creating a Factory method in the root superclass.
>
> In general, what you want to do can be accomplished by using a "template
> method"... You could rewrite Import() so that the "special query string"
is
> created by a method; then you can override the method in subclasses as
> needed. But I am not sure whether this will work from a class method...
>
> Method Import( query As %String = ".." ) {
> // Replace &SQL() with another dynamic query
> Set rsCount = ##class(%Library.ResultSet).%New() // defaults to
> DynamicQuery:SQL
> Do rsCount.Prepare( "SELECT COUNT(*) INTO :OldTotal FROM " _
> ..GetTableName()
> // etc
>
> You would override GetTableName() in each subclass. In fact, there are
ways
> to get this to change dynamically if the table name is always that of the
> class that contains the method ;)
>
> But if it's a class method I'm not totally sure you can use ".." and thus
> would have to use the classname to call the method, which pretty much
> defeats the purpose :(
>
> Hope this helps and make sense!
>
> Ram�n
>
>