0 Followers · 1.1K Posts

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

Article Benjamin De Boe · Dec 15, 2021 4m read

The 2021.2 release of the InterSystems IRIS Data Platform includes many exciting new features for fast, flexible and secure development of your mission-critical applications. Embedded Python definitely takes the limelight (and for good reason!), but in SQL we've also made a massive step forward towards a more adaptive engine that gathers detailed statistical information about your table data and exploits it to deliver the best query plans. In this brief series of articles, we'll take a closer at three elements that are new in 2021.2 and work together towards this goal, starting with Run Time

2
1 752
Article Benjamin De Boe · Dec 15, 2021 4m read

This is the third article in our short series around innovations in IRIS SQL that deliver a more adaptive, high-performance experience for analysts and applications querying relational data on IRIS. It may be the last article in this series for 2021.2, but we have several more enhancements lined up in this area. In this article, we'll dig a little deeper into additional table statistics we're starting to gather in this release: Histograms

0
0 583
Question Tristan Meziere · Nov 25, 2021

Hi members,

I have these data :

 

and need to exploit the first character of cot field (Library CDU classification) like this :

 

I get this result... it's approximatively what I want... but I need it in just one line !

With mySQL I get it with just GROUP BY rcddate

In Cache SQL I have to add {fn LEFT(cot,1)} to get the counts of each first character of cot... and seems {fn WEEK(rcddate)} doesn't make the job !

There is a trick ? or I make something wrong ?

kind regards.

3
0 362
Question Bradley Larson · Dec 8, 2021

I've been accessing Cache tables from a developer/reporting side, but am now involved in a project to create a data warehouse for our application.  I'm trying to find a query I can use to return the sizes of all the tables in the database, so we can identify the largest tables and handle those individually.  Can someone give me a query I can run against our Cache database to return the sizes of all the tables from largest to smallest?  

Thanks for the help

8
0 923
Question jaroslav rapp · Dec 3, 2021

When i use &sql(SELECT ......)  in Cache I can watch the generated code
In the generated .int code and see what is happening.
Just with my normal rights

Now in IRIS I have just 4 line calling some class %sqlcq.***
With enough rights i find there is no such class but the generated .int routine
%sqlcq.IRISAPP.xEZgUjdXCCgQdZQPpRdOye1Ci2ue.1
That holds the code that i had in my .int on Cache

Can i switch this back somehow ?

7
0 554
Question Vivian Lee · Nov 18, 2021

Hi Dev Community,

I have a persistent Document class that has a FileName string property and another Question class that has an optional one-to-many relationship with Document.

I'm trying to add a SqlComputed property to the Question class (docFileName) where docFileName = Document.FileName if there is a related Document or an empty string if there isn't one. 

I'd prefer the property to be SqlComputed so that if Question.Document changes, Question.docFileName will automatically update.

Does anyone know the syntax for accessing the properties of a related object in the SqlComputeCode?

Thanks!

12
0 587
Question Alicia Watkins · Oct 29, 2021

Hi,

Is there way to set up an automated batch job in the Management Portal to execute an SQL query.  Also, how can the related view be exported.  I have executed the SQL queries and see the view and created files manually.   I could not find any related documentation on the batch processes, but I thought batch or automated jobs could be set up via the Management Portal.  Any information is appreciated...

Thanks

5
0 301
Job Romina Sarcletti · Nov 19, 2021

A permanent job opportunity has arisen for a Caché/Ensemble /Iris developer with at least 2 years experience. My client is a specialist resource provisioner of developers for high profile clients in the finance,  healthcare, retail, distribution and credit business that are mainly based in central London. My client is looking for a highly-motivated individual who thrives in an environment where problems are open-ended. If you want to apply for the job you must be a UK resident, have a proven track record of building applications using InterSystems technologies and are able to work

0
0 496
Article Jean Millette · Nov 5, 2021 2m read

One of our apps uses a class query to support a ZEN Report and works just fine in that report, producing the expected results every time. We’ve since migrated to InterSystems Reports and noticed that, for a report using the same class query, 100s of extra rows with the same column values appear at its bottom.

We eliminated InterSystems Reports as the source of the problem by recreating the same “extra rows” issue with an Excel spreadsheet calling the same class query as a stored procedure.

0
0 346
Question Nicola Sartore · Nov 4, 2021

I want to INSERT a record in a database using JDBC in  OBJECTSCRIPT. At the same time, I want to obtain the insert ID. Is there a way to achieve this using the SQL Outbound adapter?

My code is something like this now:


Property Adapter As EnsLib.SQL.OutboundAdapter;

set sql = " INSERT INTO Prenotazioni_CUP "_
                  " (ID, cf
                  " VALUES (SEQTAB.NextVal, ?) "
set status = ..Adapter.ExecuteUpdate(.rs, sql, pRequest.cfAssistito)

5
0 493
Question Nicky Zhu · Nov 3, 2021

Hi guys,

My client has a requirement to add a column of random numbers to the query result.

I wrote a function as below:

Class Utils.SqlUtility Extends %RegisteredObject
{

ClassMethod GetSomeNumber(intInput As %Integer) As %Integer [ SqlName = GetNumber, SqlProc ]
{
    Return $R(intInput)
}

}

But in the returned sql result, every row share the same value, as below,

SELECT Utils.GetNumber('456'),
ID, Citizenship, DOB, FirstName, Gender, IDNumber, LastName, PatientNumber, PhoneNumber
FROM CDR.Patient

How may I refactor the function or sql to make the random value really random on each of the rows?

Thanks.

6
0 1084
Question Evgenii Ermolaev · Oct 23, 2021

I need to execute multiple DELETE statements in a single query like this

DELETE FROM TableName WHERE ID = 2;
DELETE FROM TableName WHERE ID = 3;
DELETE FROM TableName WHERE ID = 4;

However It does not work when there're more than 2 statements and gives me an error

Expected FROM found WHERE^DELETE FROM TableName WHERE

Using IN is not an option.

9
0 401
Question prashanth ponugoti · Oct 12, 2021

I have written below method inbound adapter myAdapter Extends Ens.InboundAdapter [ ProcedureBlock ] returns -400

If i have written in any otherExtends %Persistent  cls , always returning -30 which means Table not found

ClassMethod FetchMsgCount() As %Integer
{
    set msgCount=-1
&sql(SELECT count(ID) INTO :msgCount FROM Ens.MessageHeader)
If SQLCODE=0 Quit msgCount
Quit SQLCODE
}

Could you please some one tell me where should write this class method? What I am doing wrong?

Thanks

PRASHANTH

19
0 364
Article Brendan Bannon · Jul 15, 2021 6m read

Benjamin De Boe wrote this great article about Universal Cached Queries, but what the heck is a Universal Cached Query (UCQ) and why should I care about it if I am writing good old embedded SQL?  In Caché and Ensemble, Cached Queries would be generated to resolve xDBC and Dynamic SQL.  Now in InterSystems IRIS embedded SQL has been updated to use Cached Queries, hence the Universal added to the name.  Now any SQL executed on IRIS will be done so from a UCQ class.

1
1 888
Question prashanth ponugoti · Sep 21, 2021

Hi Community

I have extended my operation class from Ens.BusinessOperation class . I want to execute below sql on cache.

&sql(Select demoVersion into :DemoVersion from demointerface.DemoInstances where ID=:demoID)

this line not even giving error.

Please suggest me how to make sure my sql query should work everytime , when i call the class method

Same code is working fine in production but not working in local:(

Thanks a lot

Prashanth Ponugoti
 

8
0 289
Question James Hipp · Sep 14, 2021

https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic…

method Export(savertn As %Boolean = 0) [ Language = objectscript ]

I am looking to export table to a text file in a programmatic way. I am not familiar with this class and how to invoke a "savertn" as input here.

Essentially I would like to Export Table (SELECT * FROM Table) and save it as a text file locally on Linux server. Is there any examples out there of that? Perhaps I need to save the query output to a global and then pass that input to the export?

Thanks,

James

2
0 447
Question JOSEPH MONEY · Sep 14, 2021

So I am working with an inherited SQL query that queries 8 different tables. 5 of which have over a million records. 
I have 3 different servers. 

Server 1, Server 2 and Server 3. They all have the same data/tables/structure across all servers. 
Server 3 has an Iris database engine and the other 2 are Cache 2015.1.4.
I have a problem with views and performance across the servers being inconsistent. 
Thankfully Server 1 is the current live server that performs "fast enough".
Server 2 is being synced from Server 1 and acts as a report server.

1
0 255
Question Florian Hansmann · Sep 13, 2021

Hello Community,

we want to use a specific index on our sql-class.

The index we want to use is called "iFilter".
Currently we use the following technique of ignoring all other indices because the automatically chosen index is always too slow. 

3
1 346
Question Virat Sharma · Sep 5, 2021

Hello everyone

I am new to cache. In an interview i was asked how to optimize a sql query.

I just said I will create index on conditions which are present in where clause. But as per interviewer I should check How query plan is getting executed. This will help in optimizing Sql queries. 

I want to know what will be the answer for how to optimize SQL query in cache. 

Thanks in advance!!

2
0 260
Question James Casazza · Aug 23, 2021

After linking in Oracle Table with Field Column's Data Types of NUMBER, my updates into these table fields are resulting in data that is being rounded to 2 decimal places. I insert a record with 1234.1234 and 1234.12 is stored.

It appears Cache xDBC might be manipulating my values prior to sending to Oracle. Is there a setting or system parameter that is controlling this? If so, is there a way to relax this from occurring so the values I send are being stored in Oracle with the same values?

10
0 668
Question Aaron Vail · Aug 19, 2021

I'm wanting to write a query in SQL that will return a row with a count for each day for a given month or year for a specific operation or configname.  The following is a start but I'm not finding what I want in the documentation to parse out the TimeLogged field of the table.  Nay help is appreciated.

SELECT count(TimeLogged), ConfigName
FROM Ens_Util.Log
where TimeLogged like '2021-07%'
and ConfigName = 'operation_Name'
group by TimeLogged

2
0 215
Question ED Coder · Aug 15, 2019

Hi, Is there a way to connect to a MYSQL ODBC? I tried using the SQL Connect class but getting an error.

Set conn=##class(%SQLGatewayConnection).%New()
Set sc=conn.Connect("databasename","username","password")

&sql(insert into ORDERS (column1, column2, column3, column4, column5) values(:value1,:value2,:value3,:value4,:value5))
sc=res.Close()
Set sc=conn.Disconnect()

But I am getting an error :

Please can you advice how I can do this?

6
0 1481