9 Followers · 1.1K Posts

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

Announcement Neerav Verma · Feb 13, 2020

Class Queries in InterSystems IRIS (and Cache, Ensemble, HealthShare) is a useful tool that separates SQL queries from Object Script code. Basically, it works like this: suppose that you want to use the same SQL query with different arguments in several different places.In this case you can avoid code duplication by declaring the query body as a class query and then calling this query by name. 

They are declared as Query items in class definitions (similar to Method or Property) in the following way:

6
0 780
Question Jonathan Ebbers · Feb 18, 2020

I'm using Cache SQL and want the ability to choose a specific index.

I've boiled the problem down to one table and simplified the query down to

SELECT *
FROM Registration.PatResp
WHERE SchedApptNum=8450022

SchedApptNum is indexed, but instead of using that column, "Show Plan" indicates that it's looping through the entire Registration.PatResp table on Id (the primary key for the table).

I've done a tune-table with no change.

SQL provides %IGNOREINDEX, which allows me to ignore a specific index, but I don't need that.  I need the reverse - %CHOOSEINDEX so that I can force SQL to use a specific index.

6
0 1305
Discussion Benjamin De Boe · Jan 9, 2020

Hi,

we're planning some work on our SQL Query Plan functionality for a future release of InterSystems IRIS and are interested to hear how you're using them today, or what'd keep you from using them. Rather than try and fit everything in a rigid survey, I thought a simple thread on our beloved DC might also reveal some use patterns that we support or could do a better job on. 

6
0 395
Question Stella Ticker · Jan 31, 2020

I am trying to get a list of all settings for all the config items of a given production using SQL . When I run the following sql as a dynamic query I am unable to access the setting names and values. Settings is a list of Ens.Config.Setting

Set query="Select Name, Production, Settings,$ListLength(Settings) "
         _"As Count from Ens_Config.Item "

Set rc=##class(%ResultSet).%New()

Set sc=rc.Prepare(query)

Set sc=rc.%Execute

While rc.Next(.sc) {

For i=1:1:Count {

  Set tSetting=$List(Setting,i)

  Set name=tSetting.Name

}
4
0 964
Question Arto Alatalo · Jan 30, 2020

A quick question regarding to SQL Query Plan:
Why these two requests have different plans, in particularly, why second request needs temp file? To me, temp file is a bad thing which should be avoided, right?

  1. select * from Test.Log where cdate = 1
  2. select * from Test.Log where cdate > 1

Plan for 1:

Read index map Test.Log.cdateIndex, using the given %SQLUPPER(cdate), and looping on ID.
For each row:
 Read master map Test.Log.IDKEY, using the given idkey value.
 Output the row.

Plan for 2:

Call module B, which populates bitmap temp-file A.
Read bitmap temp-file A, looping on ID.

For each row:

4
0 321
Question Scott Roth · Jan 23, 2020

Ok so I am way outside of my comfort zone, and had to build an application using CSP to give users the ability to access SQL configuration tables. These SQL Configuration tables will affect the data that is sent to the downstream system. 

I saw in the examples where we were able to import GIF's/IMAGES into the CSP folders to use as a reference in our CSP pages. My question is how do you do that? If I try to import through studio, it tells me the file is invalid.

Just trying to make it a little more user friendly then blocks on a page.

We are currently using Health Share 2018.1.3

Thanks

Scott

1
0 1073
Discussion Neerav Verma · Jan 16, 2020

Hi All,

We have few queries which are simple selects . For simplicity let's say there is a query that joins two tables and gets few columns and both tables have no indexes.

Select Tab1.Field1, Tab2.Field2
From Table1 Tab1
Join Table2 Tab2
On Tab2.FK = Tab1.PK
When we do query plan for this it shows approx 6 million,  however if we make a simple adjustment to the query

Select Tab1.Field1, Tab2.Field2
From Table1 Tab1
Join Table2 Tab2
On Tab2.FK = Tab1.PK
WHERE Tab1.Id > 0 (Which will always be the case)

5
0 377
Question Kevin Furze · Jan 15, 2020

cache 2017.2.1 (Build 801_3)

when I look into the "sql statements" ( sql page of the management portal ) I have lots of old statements with a lot of them frozen. many of them are %sqlcq routines (I believe these are the SLQ's I run when testing/running random SQL queries in the sql page. )

I can clearly see where I can click on an individual query and untick an individual query to unfreeze it. or delete it. but thats a painful slow process. I can't see anywhere to delete/change multiple queries

2
0 294
Question Scott Roth · Jan 10, 2020

I am working on a BPL to take data from a MS SQL database and create an HL7 Materials Message for our EMR.  I have done this plenty of times in the past however I am running into an error.

"Remote Gateway Error: JDBC Gateway SP execute(0) error 0: Access to the remote server is denied because no login-mapping exists."

What is confusing is that this BPL doesn't differ from any of my other BPLs in connecting to MS SQL Server. I know I am missing something..

This BPL will execute the 1st Stored Procedure without any issues, the issue is when it comes to executing the second stored procedure.

3
0 848
Question Jorge de la Garza · Jan 9, 2020

I have an array of table names that I want to iterate over and for each table, get the number of rows.  I was hoping I could do something like:

set tStatement = ##class(%SQL.Statement).%New()set tSC = tStatement.%Prepare("SELECT COUNT(*) AS ObservedRowCount FROM ?")$$$ThrowOnError(tSC)set tTableName = ""for{  set tTableName = $O(tCounterAry(tTableName))  quit:tTableName=""set tResult = tStatement.%Execute(tTableName)
  // ...
}

But that doesn't work:

ERROR #5540: SQLCODE: -1 Message:  IDENTIFIER expected, ? found^ SELECT COUNT ( * ) AS ObservedRowCount FROM ?
2
0 677
Question Scott Roth · Dec 20, 2019

I have a case where I have an external table that lives out in MS SQL. Using Ensemble Security functions has anyone created a csp or cls page that acts like a portal to allow users to Update a multidimensional table without knowing SQL? I could clone the EnsPortal.LookupSettings but that was made for LUT which are only 2 columns.

I know its a long shot but trying to see if there was anything off the shelf that I can use to help meet the requirements of this project.

4
0 319
Article Peter Steiwer · Jan 6, 2020 4m read

What is %SQLRESTRICT

%SQLRESTRICT is a special %FILTER clause for use in MDX queries in InterSystems IRIS Business Intelligence. Since this function begins with %, it means this is a special MDX extension created by InterSystems. It allows users to insert an SQL statement that will be used to restrict the returned records in the MDX Result Set. This SQL statement must return a set of Source Record IDs to limit the results by. Please see the documentation for more information.

Why is this useful?

This is useful because there are often times users want to restrict the results in their MDX Result Set based on information that is not in their cubes. It may be the case that this information may not make sense to be in the cube. Other times this can be useful when there is a large set of values you want to restrict. As mentioned before, this is not a standard MDX function, it was created by InterSystems to handle cases were queries were not performing well or cases that were not easily solved by existing functions.

0
2 732
Question David Foard · Dec 26, 2019

Is there a way to get a good performing index on a date field? I have tried various date property indexes and the query plan is always in a pretty high range. Below are query plan result values I have observed:

   StartDate > '2019-12-01'  --cost = 699168
   StartDate = '2019-12-21'  --cost 70666
   StartDate between '2019-12-21' and '2019-21-28' --cost = 492058

The query plans above were for type %TimeStamp.

7
0 705
Question James Woo · Dec 16, 2019

I configured a SQL inbound adapter to monitor my local Cache database.

But I got "ERROR <Ens>ErrOutConnectFailed: ODBC Connect failed for 'SAMPLES' /
'' with error ERROR #6022: Gateway failed: DSN/User Connect."

Same error if the DSN setting is blank or set to my namespace.

Question is whether SQL inbound adapter is for external database server ONLY?
 

3
0 379
Question Guillaume Lepretre · Dec 4, 2019

Hello,

I've got a table with many attributes and data. There is 10 000 000 registrations approximatly.

I need to make a research on this table with filters, paging,  and order.

You can see an example of my  SQL request : 

SELECT * FROM ( SELECT TOP ALL  * FROM ANCV_Data.Titre WHERE etatTitre = 'Emis' ORDER BY numRemise desc) v WHERE %vid BETWEEN 1 AND 25

Cause there are many data on my table, my SQL req is  too long if I don't have index on my attributes BUT there are many associations possible...

Are they any solutions ?

Regards,

1
0 281
Announcement Tony Coffman · Dec 2, 2019

BridgeWorks is pleased to announce a VDM, v9.1.0.1.  This release includes the following updates:

Updates

  • Historical Linking is now based off connection profile name
  • Saved Formatting is now based off connection profile name
  • Tables and Fields column headers no longer hide based on connection type

Bug Fixes

  • Cross tab would not load data correctly in Finished Reports Viewer if it was in a report footer
  • Fixed an issue where refreshing logs would not work correctly after viewing a SQL statement
  • Views were not visible for available schemas on the connection wizard

New

0
1 298
Question Bálint KONCZ · Dec 2, 2019

Hello Community,

I would like to work in SQL developer with the tables from Caché.

Is it possible with JDBC tool?

What is the whole process in order to work in SQL developer?  I have the access information to Caché, but i can only choose in SQL Developer software only Oracle or MySQL database type, therefore i think, that have to install any  other tool.

Thank you in advance for your help!

br,

bálint

2
0 1018
Question Neerav Verma · Nov 28, 2019

HI,

I have made a query with class definitions and all their properties and put them in a view.

All is good besides Parameters is showing junk characters. Is there a way to do it cleanly besides getting into the code??

SELECT 
CC.ID As CompiledClass, 
CC.SqlSchemaName,
CC.SqlTableName,
CP.Name As PropertyName, 
CP.SqlFieldName, 
CP.Type,
PD.Parameters

FROM %Dictionary.CompiledProperty CP
JOIN %Dictionary.CompiledClass CC
ON CP.Parent = CC.ID

JOIN %Dictionary.PropertyDefinition PD
ON PD.ID = CP.ID1

11
0 493
Question Abbad Minhas · Nov 11, 2019

I have the following class: 

Class P.RA.SII.F
{


Query ClosedFutures(FromDate As %Date, ToDate As %Date) As %Query(ROWSPEC = "FundCode:%String, Asset:%String, TradeDate:%Date,BuySell:%String, Price:Data.Common.Numeric, Quantity:%Numeric, CumulativePosition:%Numeric, PreviousCumulativePosition:%Numeric, ClosingTrades:%Integer, ClosingTradesInPeriod:%Integer, ClosedTradeValueInPeriod:Data.Common.Numeric, NetQuantityInPeriod:%Integer, WeightedClosedAverageTradePriceInPeriod:Data.Common.Numeric, InitialTradeDate:%Date, InitialTrade:%Integer, LastInPeriod:%Integer") [ SqlProc ]
{
}

3
0 266
Question Oliver Wilms · Nov 28, 2019

Hello,

I work with Ensemble Business Operation with SQL Outbound Adapter. I try to query a DSN defined database that happens to be Cache on the same machine in the same instance of Healthshare 2017.1.3. This worked fine on Linux server when I used JDBC driver. Now I want to run it on my Windows 10 laptop. I set up DSN and I can test connection successfully. I provided DSN in Operation DSN setting and I tried with and without Credential. I get ERROR <Ensd>ErrOutConnectFailed: ODBC Connect failed for 'myDSN'  / 'myDSN' with error ERROR #6022: Gateway failed: DSN/User Connect.

3
0 938
Announcement Tony Coffman · Nov 20, 2019

Hello InterSystems Community,

We're excited to announce that we've completed our first Open Exchange submission for InterSystems platforms.

BridgeWorks VDM is an ad hoc reporting and graphical SQL query builder application that was designed for any user who needs access to their SQL projections in InterSystems Caché, InterSystems IRIS, InterSystems IRIS for Health databases as well as access to InterSystems DeepSee and InterSystems IRIS BI Cubes with minimal SQL scripting experience.  

VDM features:

0
1 559
Question Matías Peña · Nov 15, 2019

Hello everyone, It is my first post in the community. Very recently I started working using IRIS, creating services with Cache. Today they gave me a new task and I'm really lost.

How can I use an oracle database to create services using iris?

Throughout the day I was looking for a guide to use a remote Oracle database. but unfortunately I only managed the connection in SQL Gateway

5
0 1223