9 Followers · 1.1K Posts

SQL is a standard language for storing, manipulating and retrieving data in relational databases.

Question Aditi Goswami · Dec 28, 2016

Hello,

I read the Cache Documentation where it describes Private Property as below:

Specifies that the property is private. Private properties can only be used by instance methods of this class (or its subclasses).
A private property is not displayed in the catalog information (accessed by using %Library.SQLCatalog) and is not returned by a SELECT * query. However, you can explicitly refer to and use a private property in an SQL query.
 
Can someone please explain how to explicitly refer or use the private property in an SQL query?
7
0 760
Question Mack Altman · Dec 2, 2016

We don't often use SQL within our org, which is mostly due to the performance issue we experience due to the quantity of data we are reviewing.

Aside from the standard performance measures for non-Caché databases, are there any recommended approaches when querying large tables?

The table would have roughly 50M records, but there are not a finite amount of sub-nodes.

7
0 1093
Question John Hotalen · Nov 30, 2016

Hello Fellow Caché Developers,

The purpose of this post is to ask for everyone's thoughts and input around the use of transient, SQLCalculated/Computed properties within persistent classes.

This approach allows for extra data values needed in SQL queries to be available without having to join to other tables.

Very simple/basic example to illustrate the topic:

Let's say I have a persistent class named ICDAutoCodeDefn to hold ICD Auto-Coding definitions, such as:

Class ApplicationName.DB.MedicalCoding.ICDAutoCodeDefn Extends %Persistent

That has a few properties:

SpecimenPart As %String

4
0 955
Question Scott Beeson · Feb 12, 2016

 Error:

    [SQLCODE: <-400>:<Fatal error occurred>]
    [Cache Error: <<SUBSCRIPT>%0AmEdun+4^%sqlcq.HSREGISTRY.cls966.1 ^||%sql.temp(1,"")>]
    [Location: <ServerLoop - Query Fetch>]
    [%msg: <Unexpected error occurred:  <SUBSCRIPT>%0AmEdun+4^%sqlcq.HSREGISTRY.cls966.1 ^||%sql.temp(1,"")>]

Here is an example of a query that gives the error:

    SELECT COUNT(DISTINCT Criteria) as Relevance FROM HS_IHE_ATNA_Repository.Aggregation
    WHERE EventType = 'CROSS GATEWAY QUERY'

The content of the actual field is XML, but the query simply returns a number.  Here is one that works:

10
0 4929
Question Jiri Svoboda · Nov 29, 2016

I have a class which defines a property as array of %String. Is it possible to index values of this property and use this property in SQL?

I have tried 'Index idx On prop(ELEMENTS)' and then a select from the generated collection table, but this is still orders of magnitude slower than queries to the containing class.

2
0 594
Question Chip Gore · Nov 14, 2016

In writing some code on:

Cache for Windows (x86-64) 2015.1 (Build 429U) Fri Feb 13 2015 14:37:23 EST

I noticed an unexpected "ROLLFAIL" error when a Unique Index fail was generated in a %Save() call.

The object SHOULD fail to save, since the Unique criteria is not met, but I didn't expect to see a ROLLFAIL error as the "Last Error".

When running the following class code:

4
0 1164
Question Albert Forcadell · Nov 17, 2016

i have this error

DrawTableError : <MAXSTRING> zDrawTable+349^%CSP.Util.TablePane.2

perhaps i have the possibility of Deleting all history queries, but i think better to check the table where last queries were stored and solve it by deleting wrong registries. anybody knows where is the table 'QueryHistory'.

3
0 373
Question Scott Beeson · Nov 18, 2016

I get this on some queries in some namespaces.  For instance, this query:

SELECT TOP 10 SessionId, datediff(s,min(TimeCreated),max(TimeCreated)) as ResponseTime
FROM ens.messageheader
GROUP BY SessionId
ORDER BY ResponseTime DESC

It works fine in HSBUS but in HSREG it throws the error.

Server closed communication device

Does anyone know what would cause this? Would it log something more useful somewhere?

7
0 1157
Question Albert Forcadell · Nov 16, 2016

Since now i have been working from external connection but i want to work with the SQL utility of Management Portal

i dont know how to do with several instructions like in other editors like this example

update Prod.Articulos set Alto = 1646, Ancho = 16, Fondo =  80 where CodigoNum = '100' and Empresa = 'CO'
update Prod.Articulos set Alto = 1646, Ancho = 16, Fondo =  400 where CodigoNum = '101' and Empresa = 'CO'
update Prod.Articulos set Alto = 1646, Ancho = 16, Fondo =  400 where CodigoNum = '102' and Empresa = 'CO'

it returns

11
0 826
Question Mikhail Khomenko · Nov 10, 2016

Running TuneTable accounts among other the parameter named Block Count. In documentation, we see that this is an approximate numbers of 2K-blocks in which SQL-maps are stored. Databases in recent Cache doesn't support 2K-physical blocks so SQL-blocks are not physical blocks as it seems. So two questions:

- what are these blocks?

- how knowledge about count of blocks can help in SQL optimization?

Thanks for intelligent answer to stupid questions!

4
0 612
Article Matthew Giesmann · Nov 8, 2016 4m read

Beginning in Caché 2013.1, InterSystems introduced Outlier Selectivity to improve query plan selection involving fields with one atypical value.

In this article, I hope to use an example 'Projects' table to demonstrate what Outlier Selectivity is, how it helps SQL performance and a few considerations for writing queries.

Selectivity

1
0 805
Article Scott Beeson · Nov 4, 2016 2m read

I've asked a lot of questions leading up to this, so I wanted to share some of my progress.

The blue line represents the number of messages processed.  The background color represents the average response time.  You can see ticks for each hour (and bigger ticks for each day).   Hovering over any point in the graph will show you the numbers for that period in time.

This is super useful for "at a glance" performance monitoring as well as establishing patterns in our utilization.

Here is the query used:

2
0 584
Article Kyle Baxter · Aug 29, 2016 6m read

This post is the direct result of working with an InterSystems customer who came to me with the following problem:

SELECT COUNT(*) FROM MyCustomTable

Takes 0.005 seconds, total 2300 rows.  However:

SELECT * FROM MyCustomTable

Took minutes.  The reason for this is subtle and interesting enough for me to write a post about.  This post is lengthy, but if you scroll to the bottom I'll write a quick summary, so if you've gotten this far and think you've already read enough, scroll to the end to get the main point.  Check for the sentence in bold.

11
0 1456
Question Paul Mathieson · Oct 26, 2016

Hi All,

            I have a general query in regards to developers experience on extracting data from cache databases and the most efficient way to do so. I work with a number of clients who have applications with cache databases and require the data off the host system and onto data warehouse platforms for research and analysis. Often they require the data in source state which means the extracts are often simply a table scan of the entire database table without any aggregation or manipulation.

2
0 1919
Question Scott Beeson · Oct 18, 2016

This tells me that there is no timezone offset on this table/field:

Select TOP 1 GETDATE() as Now, TimeCreated FROM ens.messageheader ORDER BY TimeCreated DESC;
Now                 TimeCreated         
------------------- ------------------- 
2016-10-18 16:16:49 2016-10-18 16:16:31 

So why is TimeCreated in this resultset 4 hours less than OneMinuteAgo when I'm clearly requesting only records with a TimeCreated greater than OneMinuteAgo?

13
0 917
Question Scott Beeson · Oct 11, 2016

I have a list of about 100 MPI IDs that I would like to run a report on.  I want to list times that any data for these patients were accessed.  Currently in "Managed Reports" we have a "Disclosure Report" which I think was a custom development effort, but it is per-patient.

I have a SQL query for the ATNA log but I'm not confident in its accuracy, so I thought I'd reach out and see how other Information Exchange's might get this data.

7
0 587
Question david clifte · Sep 27, 2016

Hello,

I need to create a query that return the amount of heath related information from a patient. 

I created one using the Analitics but, once our Analitcs database is update once a day this information is not reliable during the current query day.

Part of my Analitcs query is shown below. Where can I find the equivalent tables in Health Share? Any help is appreciate.

Tanks In Advance.

--Analitcs Query

6
0 516
Question Scott Beeson · Oct 6, 2016

I experience this constantly with Cache SQL.  Especially when querying the ATNA log.

SELECT TOP 400000 * FROM HS_IHE_ATNA_Repository.Aggregation ORDER BY ID DESC

That took 12 seconds.  I then upped the number to 500,000 and it took 185 seconds.

Shouldn't the execution time scale proportionately?

If I run the 500,00 query again it takes 2.4 seconds.

4
0 521
Question david clifte · Oct 5, 2016

I have to connect to an external database and I'd like to use the JDBC SQL Gateway.

I followed this tutorial [1] to create a JDBC SQL Gateway and after configured it works as expected, but I don't know

how use this connection into source code. Maybe these other tutorial is related [2] and [3].

[1] http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY…

[2] https://community.intersystems.com/product-documentation/intersystems-p…

5
0 1106
Question Scott Beeson · Sep 27, 2016

I need to do an UPDATE via SQL and I would like the statement to return the `ID` column of each row that is updated.  MS SQL has an "OUTPUT" statement, but I don't see anything similar in Cache.  Is there a way to do this?

4
0 885
Question Rich Taylor · Aug 18, 2016

I have setup an async reporting mirror member with Read only access.  My problem is that if I try to do any sql reporting against that data I am getting errors.  I am sure that this is because the DB is read only, but I had assumed that setting up a reporting mirror would handle this.

I there a setting or mapping  I am missing?

7
0 838
Question Neeraj Mehta · Sep 15, 2016

I have been using the query below and it was working fine but now it's giving a SQL error. There were no changes made that could cause this to stop working. There is no Field 'APPLICATIONID' in the table.

QueueSQL=select distinct (convert(char(5),SkillsetID)+'='+Skillset) from iagentbySkillsetStat where ApplicationID > 10000
QueueMappingSQL=SELECT DISTINCT (convert(char(5),SkillsetID)+'='+Skillset), SkillsetID FROM iagentbySkillsetStat iagentbySkillsetStat WHERE (iagentbySkillsetStat.ApplicationID>10000)

DB- Intersystems Cache

Error details for the log files are below.

6
0 4438