Solved

Get list of Tables and Views from Intersystems.Cache

Posted on 2014-03-28
5
1,610 Views
Last Modified: 2014-05-16
Hi,

We have some 3rd party software that uses an older version of Intersystems Cache to store it's data.  We have access to query it through the Intersystems.Data.CacheClient.dll (custom ODBC driver that comes with it)

I can query a database table fine, but I am trying to get a listing of the tables and/or views that exist in a database and I can't figure out how to do that.   I am working in VB.NET.  

I also notices there is a Intersystems.Data.CacheTypes class that might be helpful, but I am not sure.

Lastly, the Views don't seem to be query-able directly.  Is that normal or am I doing something wrong?

Any help with any of the above would be welcome.  Thanks in advance...
0
Comment
Question by:MRS
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
Querying direct you could try:
select top 100 SqlTableName, classtype
   from %dictionary.compiledclass
   where classtype in ( 'persistent', 'view' )

Open in new window

0
 

Author Comment

by:MRS
Comment Utility
Thanks for the reply Carl.

I tried that and also something similar that I found online.  I get back the following error through.

Error: [SQLCODE: <-30>:<Table or View not found>]
[Cache Error: <<SYNTAX>errdone+1^%qaqqt>]
[Details: <FLoop - func = DQ>]
[%msg: < SQL ERROR #30: Table '%DICTIONARY.COMPILEDCLASS' not found>]

Any ideas how I might get around that?
0
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
How are you attempting to talk to the database?

I used the following to make a basic ODBC call:
Dim cn As New OdbcConnection("DSN=ENSEMBLE2013 Samples")
Dim adap As New OdbcDataAdapter("SELECT SqlTableName, classtype FROM %Dictionary.CompiledClass", cn)

Dim dt As New DataTable
adap.Fill(dt)

For Each row As DataRow In dt.Rows
    Console.WriteLine(row(0).ToString())
Next

Open in new window

0
 

Author Comment

by:MRS
Comment Utility
Basically the same thing you show above, but instead of the ODBC objects, I am using a Cache data Objects.  I keeps throwing the error about not knowing what the @Dictionary.CompiledClass is.  

Could it be the ODBC object that is allowing it?  Can I connect to Cache with an ODBC object without creating an DSN on the machine?

Using Connection1 As New CacheClient.CacheConnection(IP, Port, nSpace, User, Pass)
    Connection1.Open()
    Using Adapter1 As New CacheClient.CacheDataAdapter("SELECT SqlTableName, classtype FROM %Dictionary.CompiledClass", Connection1)
        Using tbl As New DataTable
            Adapter1.Fill(tbl)
            For Each dr As DataRow In tbl.Rows
                Console.WriteLine(dr(0).ToString)
            Next
        End Using
    End Using
    Connection1.Close()
End Using

Open in new window

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
You should be able to. A DSN-less connection string would be along the lines of:
Dim cn As New OdbcConnection("Driver={Intersystems ODBC35};Server=localhost;Port=1972;Database=Samples;UID=*****;PWD=*****;")

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now