9 Followers · 1.1K Posts

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

Question Stefan Cronje · Nov 10, 2021

Hi,

We need a web-based SQL tool to connect to Ensemble/Cache, that will offer more functionality than what the Management Portal offers.
It needs to be web based, so that we can host it on a machine that has connectivity to the server via the superserver port. We (the devs and support) only have browser access to the environment via Remote Desktops, hence the requirement.

Has anyone gotten OmniDB to connect to Ensemble/Cache? If so, can you please advise on how to configure it?

Any other suggestions for such a tool are also welcome.

Kind regards,
Stefan

1
0 343
Article Evgeny Shvarov · Sep 20, 2021 3m read

Hi folks!

Sometimes we need to import data into InterSystems IRIS from CSV. It can be done e.g. via csvgen tool that generates a class and imports all the data into it.

But what if you already have your own class and want to import data from CSV into your existing table?

There are numerous ways to do that but you can use csvgen (or csvgen-ui) again! I prepared and and example and happy to share. Here we go!

2
0 1252
Question Abdul-Rashid Yakubu · Mar 22, 2022

Hi,

Is there a way to find the median in Intersystems Cache SQL? I know it is not available as an aggregate function. Also in SQL Server I could try something like: 

SELECT
(
 (SELECT MAX(Score) FROM
   (SELECT TOP 50 PERCENT Score FROM Posts ORDER BY Score) AS BottomHalf)
 +
 (SELECT MIN(Score) FROM
   (SELECT TOP 50 PERCENT Score FROM Posts ORDER BY Score DESC) AS TopHalf)
) / 2 AS Median

However, there is no PERCENT Keyword in Cache as well. Any suggestions?

Thanks

4
0 458
Question Tom Bruce · Apr 25, 2022

Hi everyone, how do you run multiple quires?

I have tried couple of different ways, but not working.

 SET sql = 2

    Set sql(1) = "UPDATE QUERY"

    Set sql(2) = "UPDATE QUERY"

    Set sqlStatement=##class(%SQL.Statement).%New()

    Set sc1=sqlStatement.%Prepare(.sql)

    If $$$ISOK(sc1)     {

       Set tResult = sqlStatement.%Execute()    

    }

    else{

        $$$LOGERROR("Failed")

    }

4
0 1913
Question Scott Roth · Apr 22, 2022

A question has come up that I am not finding the answer for.... Does the daily purge process re-index EnsLib.HL7.SearchTable or other SQL tables?  In looking at the purge process documentation I am not seeing anything that mentions EnsLib.HL7.SearchTable. Do we have to manually constantly re-index tables that we create? For example I created another search table based off of EnsLib.HL7.Search table, will I need to constantly watch this as it grows? How do tables get index, is there some kind of mechanism that automatically does it, or are we responsible for indexing tables ourselves? We are

1
0 361
Question José Pereira · Apr 7, 2022

Hi!

I'd like to know if there are any issues if an index is inserted into a table without running the %BuildIndices() method.

It's important to note that data inserted before the index is not important for retrieval, so it's not a problem data inserted before the index don't show up in queries.

The reason why I'm asking this is that I'd like to avoid index reconstruction on big tables which I need to inser such index.

I'm using Cache 2018.1.

Thanks,

José

8
0 492
Question Scott Roth · Mar 18, 2022

We are trying to track down the source of Orphaned messages and noticed that we are unable to query EnsLib.HL7.Message with any kind of WHERE or ORDER BY clauses in our SQL statement.

I know EnsLib.HL7.Message is a system table, but is there a way we can add additional Indexes to the table to make the query run better/faster without affecting the system?

4
0 814
Question Andy Stobirski · Mar 15, 2022

How do I use the LOAD DATA command as described here.

I have the following LOAD DATA statement:

LOAD DATA FROM FILE 'E://Temp/Values.txt'

into PARIS.UAGU_MNDOOUT1 (AHSU_ID, AHSU_UAG_ID)

Where do I run it? It doesn't work in the SQL Gateway, in the terminal, in an embedded SQL command.

What am I missing?

2
0 467
Question Louie McLaughlin · Mar 10, 2022

I'm new to cache, come from an oracle and sql server background. In oracle and sql server I could write basically a stored procedure like script and pass it in as text to the command to execute. 

Example:

Below would be the _sqltext

DECLARE @Id INT;

select id into @Id from something;

 if @Id = 9 

BEGIN

do something

END

The _sqltext would work in sql server, what would be the equivalent for cache for it work?

I get a generic error when I try it with cache

using (var mdscmd = new CacheCommand(_sqlText, MyConnection) { CommandType = CommandType.Text }) {

}

Thanks

2
0 289
Question Renato Araujo · Mar 8, 2022

Hello everyone!

I am writing a SQL CALL (using JDBC) to a stored procedure that outputs a structured object (Oracle Object).

However, the adapter method is not accepting the corresponding JDBC Data Type STRUCT for the output parameter, returning the following error:

ERRO #5023: Erro no Gateway Remoto: JDBC Gateway SP execute(0) error 0: Remote JDBC error: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'AGUARDAR_EVENTO'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Declaration of Output parameter:

0
0 528
Article David Loveluck · Aug 27, 2019 28m read

Since Caché 2017 the SQL engine has included new set of statistics. These record the number of times a query is executed and the time it takes to run.

This is a gold mine for anyone monitoring and trying to optimize the performance of an application that includes many SQL statements but it isn’t as easy to access the data as some people want.

This article and the associated sample code explains how to use this information and how to routinely extract a summary of daily statistics and keep a historic record of the SQL performance of your application.

What is recorded?

7
6 1718
Question Jonathan Harris · Mar 3, 2022

I want to have a script that can run from the usual unix, linux, or aix command line. It has to be able to get into an irissession and use set statements to get data using sql. It seems like I'm in a catch-22. When I use the irissession SERVER command at the command line, I can't run a script. When I put the irissession SERVER command in a script, it won't run anything in the script after that.

My goal for this script is to get this information and put it into a file which I can then parse.

10
0 2775
Question Adam Lees · Aug 20, 2021

Use case: small in-house hospital systems that query patient demographics via SQL.  The new PAS being implemented in the near future will only support query/response via HL7.  SQL access is available but intended for reporting so up to 24 hours behind.

Probably the easiest option is to set up a database in Ensemble and keep it up to date via standard ADT feed.  This is going to have quite a large footprint and has a risk of getting out of sync.

2
0 430
Question Thembelani Mlalazi · Mar 16, 2021

I have  a SQL query that I want to run against MS SQL from cache ensemble using the SQL outbound adapter. If I run this query direct from MS SQL Studio it take about 7 seconds MAX and returns about half a million rows. The row only contains one column it is a number all same size and if I run this query in the production in ensemble it takes for ever the production finishes without getting the response back. The same query run in cache outside the ensemble environment writing results to a file it returns results taking about 3minutes to complete. But if I load the results into  a list or

1
0 345
Question Michael Angeleri · Feb 24, 2022

Hello, first question for me:

Is there a way to use a class Parameter in embedded SQL without having to declare a local variable, in a similar way to how it is done with Property by preponing i% as described here. See my example:

Class Test.Test Extends %RegisteredObject
{ 
Parameter MyParam = "1";  
Property MyProperty;  
(...)
Method PerformQuery() {
    set myParamLocalVar = ..#MyParam //this is what I would like to avoid
    &sql(SELECT * FROM MY_TABLE
        WHERE MY_PROPERTY = :i%MyProperty
        AND MY_PARAM = :myParamLocalVar)
    (...)
}
}
1
0 406
Question Warren Grob · Oct 10, 2019

I am experiencing a problem with an EDI process that uses a SQL Batch Service to connect to our DEV environment.  However, when we point the EDI service to our TEST server, it errors out.

I have checked every single property on our TEST and DEV servers as well as the properties on the associated tables.  They are identical.  Nothing has changed in the SQL either. 

1
0 369
Question Tuan nguyen · Sep 13, 2018

I can refer to the TracerName for a given ImageFile object with the following syntax: obj.Study.Injection.GetAt(obj.InjKey).RadioTracer.TracerName

Is it possible to write an SQL statement to search the PET.ImageFile table to find a match based on the RadioTracer.TracerName?

1
0 279
Question Emanuel Lazar · Sep 5, 2018

SQL gateway. 'Locking' problem.

while debugging, is there in Caché a command to 'unlock' the instance of a class ?

close class, and kill class is not enough.

same problem in %Activate link

for each debug I have to exit (Halt) the terminal, 

make debug in C#

coming back , and re-load again in Caché.

Regards,

Emanuel

1
0 386
Article Muhammad Waseem · Feb 24, 2022 2m read

Hi, Community,

This post will demonstrate how to display data on the web by using Embedded Python , Python Flask Web Framework and Jquery datatable
image

We will display processes from %SYS.ProcessQuery table.

Step 1: Add table to HTML page and write below javascript code to display passed data from app.py :

HTML

  <table id="myTable" class="table table-bordered table-striped">                 
   </table>

Javascript

0
0 2106
Article Evgeny Shvarov · Feb 19, 2022 2m read

Hi developers!

As you probably noticed in IRIS 2021 the names of globals are random.

And if you create IRIS classes with DDL and want to be sure what global was created you probably would want to provide a name.

And indeed you can do it. 

Use WITH %CLASSPARAMETER DEFAULTGLOBAL='^GLobalName' in CREATE Table to make it work. Documentation. See the example below:

11
0 705
Article Evgeny Shvarov · Feb 19, 2022 2m read

Hey developers!

Sometimes we need to insert or refer to the data of classes directly in globals.

And maybe a lot of you expect that data structure of global with records is:

^Sample.Person(Id)=$listbuild("",col1,col2,...,coln).

And this article is a heads up, that this is not always true, don't expect it as granted!

1
0 481