Solved

Get list of Tables and Views from Intersystems.Cache

Posted on 2014-03-28
5
1,656 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
ID: 39961674
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
ID: 39961717
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
ID: 39961783
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
ID: 39961882
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
ID: 39961926
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Read about achieving the basic levels of HRIS security in the workplace.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

939 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

16 Experts available now in Live!

Get 1:1 Help Now