9 Followers · 1.1K Posts

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

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 706
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 482
Question Oleksandr Kyrylov · Feb 2, 2022

Hi everyone, i cant understand what is wrong in my query: 

ALTER TABLE MyNamespace.MyTable ALTER COLUMN CurrentColumnName RENAME NewColumnName

I just want to rename column name using sql.

I could not find any life example using this syntax.

SQLCODE for this query is -25:

-25 Input encountered after end of query

Quote from documentation:

12
0 945
Article Muhammad Waseem · Jan 11, 2022 2m read

In this article I will explain the usage of %SQL_Diag.Result and %SQL_Diag.Message table along with all-new LOAD DATA functionality.

It is recommended to go through LOAD DATA documentation first. 

After successful operation LOAD DATA insert one record in %SQL_Diag.Result table and details are inserted in %SQL_Diag.Message table


Below is the basic command when table is already created and source file does not contain header row. 

LOAD DATA FROM FILE 'C://TEMP/mydata.txt' 
INTO MyTable

The file name must include a .txt or .csv (comma-separated values) suffix and both source and target have the same sequence of data columns.

Loading from File Source: Header

1
0 358
Article Matthew Giesmann · Jan 28, 2022 2m read

We recently encountered an Embedded SQL issue while upgrading to IRIS 2021.1, and thought the issue and workaround might be interesting to share.

Key takeaway:  Host variables in an ORDER BY clause of an embedded SQL query that is inside of a method don't work as expected. IRIS versions starting with 2020.1 are affected. As a workaround, add the host variable to the Method's PublicList list and "new" them so the embedded query has access to them.

1
0 457
Question Robert Cemper · Jan 12, 2022

II try to explore the new SQL LOAD DATA  feature in SQL comparing it to SQL INSERT

I'm stuck at this point:  INSERT INTO <table> (columns...) VALUES  (.....)
allows having not just simple column references but also ALL Standard SQL FUNCTIONS (at least)
example:  

INSERT INTO Test (ShortName,DOB)VALUES  (SUBSTRING(Name,1,4),TO_DATE(displayDate,'MM-DD_YYY')) 

This works perfectly. 
BUT the same VALUE clause applied to LOAD DATA  fails in various ways:

LOAD DATA FROM FILE '/irisrun/repo/LoadSQL.txt'
INTO Test (ShortName)  VALUES (SUBSTRING(Name,3,4))
USING {"from":{"file":{"header":"1"}}}

3
0 331
Question Oliver Wilms · Jan 8, 2022

I have csv date file with date values like this "4/10/2021" for April 10, 2021. I defined a table with this property: Property TranDate As %Library.Date.

I capture error

[SQLCODE: <-104>:<Field validation failed in INSERT, or value failed to convert in DisplayToLogical or OdbcToLogical>] [Location: <ServerLoop>] [%msg: <Field 'dc_data_finance.transact.TranDate' (value '4/10/2021') failed validation Field ...

I do not really want to change TranDate to %String. How can I import "4/10/2021" into %Date property?

10
0 686
Article Oliver Wilms · Jan 8, 2022 2m read

I have a csv file with 13 columns.

The header row is:

"Date","Check","Merchant","Category","SubCategory","Memo","Credit","Debit","Bill Pay","Debit Card","Account","Balance","Status"

The first data row is:

"","","","","","","","","","","Cash","56",""

I have created a SQL table to LOAD DATA into. When I ran

LOAD DATA FROM FILE '/irisrun/repo/data/finance-transactions-08-Jan-2022_08-25.csv' into dc_data_finance.transact

I got Cash into “Account” property (correct) and I saw 56 in “Status” property. I want to skip the “Balance” column. I updated my LOAD DATA statement to:

1
0 295
Question Andreas Schneider · Dec 30, 2021

Hi all,
I try to build a little project for the dataset contest, you can find it here on github: Openflights dataset
My plan is to use just plain SQL. So I've made a few experiments with the new feature LOAD DATA.

Unfortunately all loads produce errors like:  
 Error: [SQLCODE: <-400>:<Fatal error occurred>]
[Error: <<UNDEFINED>zExecute+83^%sqlcq.OPENFLIGHTS.cls4.1 *%qparsets>]
[Location: <ServerLoop>]

The statements I use looks like this:

 

10
0 982
Article Oliver Wilms · Dec 24, 2021 4m read

One of my colleagues had developed an interface in Health Connect (HealthShare 2019.1) to add large amounts of data to an external SQL Server database. The data comes from many text files with delimited rows and data for one table per file. There is a business process to read a file line by line and send an Insert Request to an operation. The request contains an Insert statement like ‘Insert into TABLE columns (col1, col2, … colZ) values (val1, val2, … valZ).’ The Health Connect operation utilizes Outbound SQL Adapter to insert one row into a table per request. You can probably imagine this

0
0 399
Question Jimmy Christian · Jun 16, 2021

Hello Community,

I am trying to insert multiple values in a table. Below is the simple sql statement.

Insert Into TableX

values ('Name', 'Address', 'Phone')

How can i do multiple inserts(rows) in one single statement?

Values are not in another table, so i cannot use Select into.

Thanks,

Jimmy Christian.

14
0 1103
Question Alicia Watkins · Nov 1, 2021

Hi there,

Does anyone have an example of the method used to run an SQL query and generate the view in a Mumps routine.   I have several SQL queries created from a vendor that need to be converted and the corresponding view referenced.  I cannot seem to find any examples in IDX routines or in the  IRIS/Cache documentation.  Any help is appreciated.

-Alicia

5
0 619
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 Plan Choice.

It's hard to figure out the right order to talk about these (you can't imagine how often I've reshuffled them in writing this article!) because they fit together in such a nice way. As such, feel free to go on a limb and read these in random order smiley.

2
1 827
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 667
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 408
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 1045
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 604
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 692
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 355