9 Followers · 1.1K Posts

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

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 518
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
1 374
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 547
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 1177
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 469
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 429
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 950
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 354
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 529
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 291
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 419
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 312
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 815
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 255
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 1523
Question reach.gr G · Aug 4, 2021

Trackcare 2021.2

Please may I know  how to access SQL parameter with string as datatype with NO reference to SQL Table and SQL Column.

Hi Experts,

I have these two clarifications to make:

  1. I am struggling to understand the process and method of accessing the SQL table with no reference to SQL parameter or Table but string

This is what I tried: Tired to create ERD diagrams and try to extract Primary and Foreign keys to associate, but I cannot in this case

I would like to do something like this

6
0 3356
Question reach.gr G · Jul 16, 2021

Dear Experts,

I have to pull out a report of certain code tables and this is my first script and I need to write many.

1. If I have to refer to the table, seeing the reference in the components with reference to SQL table and column, 

can I use Select < What I need from the table>

Inner join with reference table? 

I tried, I used the code table reference in the components, but I am getting errors, 

Code Table
Code    CT_abc
Loc ID
Type

P: Public

Pv: Private

C: Community

3
1 401
Question Mark Runyan · Jul 6, 2021

How strange this is to me.  I'm querying a table against a numeric(15,2) column call max_client_resp_service.  When I query max_client_resp_service > 0 or any number, I get results, but they are not always right, for example where max_client_resp_service > 5 returns values less than 5, e.g. 2.00.  When I query < 110 of any higher number I get zero results.  It's as though the comparison operator, especially less than function is not working.  See attachments for screen shots.  I'm stumped.  Ok looking at this further, it appears ">" returns all records, "<" returns no results.

6
0 346
Question David.Satorres6134 · Jul 20, 2021

Hi,

When for any particular reason I need to update a record and don't want to pull the triggers, the keyword %NOTRIGGER can be used. But I've been trying to do the same when I change the row using the object approach, but I can't find it. Anyone knows if it's possible to avoid pulling triggers when working with objects?

Sadly, the utility "DISABLE^%NOTRIGGER" doesn't seem to exist ;-)

Thank you,
David

2
0 351
Question Kevin Pickering · Jul 14, 2021

Apologies if this isn't the correct forum but here goes..

I'm accessing an Intersystems database from MS SQL Server using Intersystems ODBC driver and using OPENQUERY statement to read metadata of tables using

SELECT * FROM OPENQUERY([<linked server name>], 'SELECT * FROM INFORMATION_SCHEMA.COLUMNS')

but I get an error message saying INFORMATION_SCHEMA.COLUMNS cannot be found.

Intersystems SQL documentation does reference this table so is there some other way to access this table or is it maybe a permissions issue?

3
0 824
Discussion Stephen Canzano · Jul 19, 2021

When I'm asked questions about SQL, I like Intersystems staff at the WRC, generally ask about the Query Plan.  My feeling is that even before you run a query you should examine the results of Show Plan to confirm that the code is going to give me the results in the manner I would expect.  If I expect it to leverage an index and I see that it is not then I go back and look at what I might have done incorrectly and try to re-write the query to get the index behavior I'm looking for.  To that end, there's a poll below to ask you if think moving the Show Plan button as the first button would be

0
0 203