0 Followers · 1.1K Posts

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

Question Dmitry Maslennikov · Apr 3, 2023

In some testing scenarios, I need to clone the database. While I use only SQL access.

I need all data to be cloned, not mapped from the original database, and a separate database to be accessed.

Is there any way to do so?

Something like

CREATEDATABASE [Databasetocreate]
WITHTEMPLATE [Databaseto copy]
1
0 277
Question Michoel Reach · Mar 28, 2023

In the documentation  Data Types | Caché SQL Reference | Caché & Ensemble 2018.1.4 – 2018.1.8 (intersystems.com)

it says that "by default, Caché establishes a system-wide ODBC VARCHAR maximum length of 4096; this ODBC maximum length is configurable"

Per instructions, I went to SMP -> System -> Configuration -> General SQL Settings, where most of the fields from  $SYSTEM.SQL.CurrentSettings()

appear. That one does not.

How does one change it, and can it be increased?

Thanks!

[Cross-posted from https://groups.google.com/g/intersystems-public-cache/c/eRFeORb_sb0]

2
0 378
Article Guillaume Rongier · Mar 29, 2023 1m read

Quick Tips: Total Productive Maintenance

Named parameters can be achieved with SQLAlchemy :  

from sqlalchemy import create_engine, text,types,engine

_engine = create_engine('iris+emb:///')

with _engine.connect() as conn:
    rs = conn.execute(text("select :some_private_name"), {"some_private_name": 1})
    print(rs.all())

or with native api

from sqlalchemy import create_engine, text,types,engine

# set URL for SQLAlchemy
url = engine.url.URL.create('iris', username='SuperUser', password='SYS', host='localhost', port=33782, database='FHIRSERVER')

_engine = create_engine(url)

with _engine.connect() as conn:
    rs = conn.execute(text("select :some_private_name"), {"some_private_name": 1})
    print(rs.all())
0
0 517
Article Julian Matthews · Mar 17, 2023 7m read

Introduction

Say you have a receiving system that accepts HL7 and provides error messages in field ERR:3.9 in the ACK it returns. You require a different reply code action depending on the error message, however the Reply Code Actions settings for the operation do not provide this level of granularity. One option could be to create a process that takes the ACK and then completes the action you were expecting, however things can get a bit messy if the action is to retry the message, especially when trying to view a message trace.

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

This is the second piece in our series on 2021.2 SQL enhancements delivering an adaptive, high-performance SQL experience. In this article, we'll zoom in on the innovations in gathering Table Statistics, which are of course the primary input for the Run Time Plan Choice capability we described in the previous article.

4
0 818
Question Smythe Smythee · Mar 23, 2023

Hi Community,

I am trying to save data into SQL table but each entry  getting saved twice in the SQL table. Is there any reason data is saving Twice in the SQL table 

I have created a %Persistent class for the fields

Please find the business operation below

Class Patient.DBOperation Extends Ens.BusinessOperation

{

Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter";

Property Adapter As EnsLib.SQL.OutboundAdapter;

Parameter INVOCATION = "Queue";

6
0 344
Article Daniel Aguilar · Mar 18, 2023 3m read

One of the reasons why I love Cache and Iris is that not only you can do anything you can imagine, also you can do it in a lot of different ways!!.

Imagine that you have an integration running with IRIS connected by ODBC you probably only run SQL queries but you can also create stored procedures and inside write the code to do everything you can imagine.

I'm going to give you some examples but the limit is your imagination!!

You might wonder, wait!! I don't know how to create a store procedure in IRIS. But this it's not true, you know how to create them but you don't know yet!.

1
2 459
Article Heloisa Paiva · Mar 10, 2023 3m read

Introduction

This article is intended to be a simple tutorial on how to create ODBC connections and working with them, since I found starting with them a little bit confused, but I had amazing people to take my hand and walk me through it, and I think everyone deserves that kind of help too.
I'm going to divide each little part in sections, so feel free to jump to the one you feel the need to, although I recommend reading everything.
I'm going to use the sample data created in a previous article, Quick sample database tutorial: Samples.PersistentData, with the properties Name and Age.

0
1 888
Question Louie McLaughlin · Mar 6, 2023

I need a stored procedure where I can execute multiple delete from statements. 

This will work to create a stored procedure, but when I add in other delete from, get error invalid sql statements when try to create

CREATE PROCEDURE DeleteSpecimenTwo
  (IN Specno VARCHAR(50))
BEGIN
DELETE FROM PCONT WHERE PSPECNO = :Specno;
END;

This doesn't work

CREATE PROCEDURE DeleteSpecimenTwo
  (IN Specno VARCHAR(50))
BEGIN
DELETE FROM PCONT WHERE PSPECNO = :Specno;

DELETE FROM PSPEC WHERE PSPECNO = :Specno;
END;

Any suggestions

Thanks

Louie

1
0 290
Question Robert Cemper · Mar 3, 2023

For my recent tutorial, I used %Query Wizard of Studio.

Could any of the VSCode experts please show me how to generate
Query Statement with input parameters, CONTAINID , ROWSPEC
and the required class methods
- <queryname>Execute()
- <queryname>Fetch()
- <queryname>Close()

 

I was just not able to do it.
​​​​​​​
  

3
0 262
Article Heloisa Paiva · Mar 2, 2023 3m read

Introduction

This is a simple tutorial on the quickest way I found to create a sample database for any purposes such as testing, making samples for tutorials, etc.

Creating a namespace

  1. Open the terminal
  2. Write the command "D $SYSTEM.SQL.Shell()"
  3. Write "CREATE DATABASE " and the name you want for your namespace.

Now you have a new namespace in a faster way than creating it from the Management Portal - which of course offers way more configuration options.

5
1 432
Article Brendan Bannon · Aug 29, 2016 7m read

The Art of Mapping Globals to Classes 1 of 3

Looking to breathe new life into an old MUMPS application?  Follow these steps to map your existing globals to classes and expose all that beautiful data to Objects and SQL.

By following the simple steps in this article and the next two you will be able to map all but the craziest globals to Caché classes.  For the crazy ones I will put up a zip file of different mappings I have collected over the years.  This is NOT for new data; if you don’t already have existing global please just use the default storage.

26
12 6088
Question Dean Rochester · Feb 23, 2023

Newbie here...

I am looking to use fhir to gather patients in our end point that have a certain diagnosis and or certain insurance.

Is this what fhir can be used for?

In the past I have done the normal SQL query/extract to CSV file.  Looking to use fhir for this for future.

Thanks in advance for your time

Dean-O

1
1 457
Question Michael Hill · Jan 12, 2023

Is it possible to retrieve the SQL-Executing process ID (PID) from a process spawned from a UNION %PARALLEL? I have a value set in the SQL-Executing process that I need to replicate in the UNION %PARALLEL spawned process(es). The SQL-Executing process writes the value to a global subscripted by its PID so determining the SQL-Executing PID from the spawned process is what I need. I expected $ZPARENT from the spawned process would hold the SQL-Executing PID but the PID returned is different.

With thanks,

Michael Hill

11
0 441
Question Jude Mukkadayil · Jan 31, 2023

Hi,

      Can anyone please help me how to use regular expression/wild character on a sql query  for a pattern like C00.0 to C00.9, C01.0 to C01.9  and so on until C77.0 to C77.9  .

Thanks for your help

Thanks

Jude

3
0 335
Article Andreas Schneider · Jan 2, 2022 3m read

The last days I've work with the great new feature: LOAD DATA With this post I would like to share my first experiences with you. The following points do not contain any order or other evaluation. These are only things that I noticed when using the LOAD DATA command. It should also be noted that these points are based on the IRIS Version 2021.2.0.617 which is a preview release. So it may be that my observations do not apply to newer IRIS versions. But maybe they are helpful for others.

1) The file path is on server side

5
2 1141
Question Virat Sharma · Jan 30, 2023

Hi All,

I want to run an SQL like below

Select ID,Rollno,Marks,Name,Section,Teacher from Marks left outer join Student on Marks.StudentID=Student.ID

Now, the Student.ID is having the encrypted value which is not matching with Marks.StudentID (as this is clear value).

I can get the clear value using encrypted value as follow

^StoreValue("EncryptStudentID",Student.ID)=$LB("123"). That 123 is the clear Student.ID which I need to match in SQL query (ON clause).

Now I Need to fetch the data from sql query matching both clear values. Something like this

2
0 200
Question Virat Sharma · Jan 30, 2023

Hi All,

I have a below query for which I need help.

I have a persistent class User.Cars.cls. The properties of this class is mapped through Global mapping with global (^CAR(Date,CarSerialno,Seq)).

Property CarNumber as %String (TRUNCATE=1) [SqlFieldName= CAR_Number];

Mapping of 5th Piece of ^CAR global to CarNumber property.

For e.g.^CAR(Date,CarSerialno,Seq)=1^2^3^4^BMW 4567^6^7

To increase the security we have encrypted the database. 5th Piece is also encrypted in global (New value after encryption: 'ASAD=4367' through some tool technique).

1
0 214
Article Yuri Marx · Jul 20, 2022 6m read

Python has become the most used programming language in the world (source: https://www.tiobe.com/tiobe-index/) and SQL continues to lead the way as a database language. Wouldn't it be great for Python and SQL to work together to deliver new functionality that SQL alone cannot? After all, Python has more than 380,000 published libraries (source: https://pypi.org/) with very interesting capabilities to extend your SQL queries within Python. This article details how to create new SQL Stored Procedures in InterSystems IRIS Database using Embedded Python.

Python libraries used as samples

3
0 1206
Question Virat Sharma · Jan 21, 2023

Hi All,

I am currently using D $SYSTEM.SQL.Shell() command or management portal to retrieve the data from database. I just learned we can also run cache table sql queries in MS access. MS access already installed on my machine. 

I need to ask how I can connect my database of USER or sample namespace in MS access to run these SQL queries.

Thanks in advance!!

4
0 290
Question Virat Sharma · Jan 24, 2023

Hi All,

I am having an SQL query (mentioned below). When I am running this query it is taking 90 min to retrieve all records (approx 1 million records).

Fetching data from 5 tables using inner join in cache. Relative cost displaying 10 million

I wan to confirm How this query can be optimized

12
0 330
Question Virat Sharma · Jan 23, 2023

Hi All,

I am a beginner in cache. I need to extract data from multiple tables (4-5) tables based on an SQL query . The data is more than 9 lakhs of records (i checked using count). The total number columns is 16. 

When I am running this SQL query through management portal, I am getting time out exception. Could you please suggest how I can retrieve those records. Which way will be good (Dynamic query using %SQL.Statement or Embedded SQL (not known to me) or Writing to a global will help or not). 

4
0 385
Question Joe Jones · Jan 18, 2023

Hi community,

I am working on Converting Non HL7 message (Using record maps) into HL7 message.

1.Can anyone share few details how to save Non HL7 message into SQL table and the converted HL7 message into SQL table

2.In Message Viewer is there any SQL tables are linked to the session id or where the information regarding the message will be stored? Will the message trace details are stored in globals or in SQL table,If yes can anyone share the details in which tables or globals will it be stored?

Joe

2
0 389