Hello, I wonder if we can run SQL queries to find data in Lookup tables?
SQL is a standard language for storing, manipulating and retrieving data in relational databases.
SQL is a standard language for storing, manipulating and retrieving data in relational databases.
Hello, I wonder if we can run SQL queries to find data in Lookup tables?
I have written below method inbound adapter myAdapter Extends Ens.InboundAdapter [ ProcedureBlock ] returns -400
If i have written in any other Extends %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
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.
Why did InterSystems do this? Good Question! The big win here is flexibility in a live environment.
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
I have an ObjectScript class with a Log property of type %Stream.GlobalCharacter. I need to search the end of each of the logs - is there a way to extract the last 10 lines of the Log stream for each object via SQL? Or is my only option to write an ObjectScript routine to walk the table and inspect each Log property one by one?
Thanks!
Hi Community,
We're pleased to invite you to the upcoming webinar in Spanish called "IntegratedML - Creating ML models in minutes"!
Date & Time: September 30, 4:00 PM (CEST)
Speaker: @Eduardo Anglada, Sales Engineer, InterSystems Iberia
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?
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.
And Server 3 is supposedly a new Live server.
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.
SELECT TOP 100 d0.ID FROM %IGNOREINDEX Belegindex %IGNOREINDEX KundenNrGlobalindex %IGNOREINDEX Rechnungsnummerindex %IGNOREINDEX Erfassungsartindex %IGNOREINDEX Belegsuche %IGNOREINDEX DatumAuftragindex %IGNOREINDEX OnlineBestellnummerindex %IGNOREINDEX Belegnummerindex %IGNOREINDEX KundenNrGlobalindex %IGNOREINDEX VAMindex %IGNOREINDEX BelegnummerbeiLagerLagerBestellungIndex %IGNOREINDEX iStatusSolr db.BelegeKopf AS d0 WHERE (((d0.KundenNr = 'BUKR01')) AND d0.ErfassungsartBez IN ('AB', 'AN') AND d0.DatumAuftrag >= '2020')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!!
How Can I Do It (rebuild index) using ObjectScript?
.png)
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?
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
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))
s sc=res.Close()
Set sc=conn.Disconnect()
But I am getting an error :
Please can you advice how I can do this?
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:
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
Select * FROM
SQLUser.SS_User SSU
LEFT JOIN SQLUser.CT_Loc CTL ON CTL.CTLOC_Desc = ?? < Cannot find Info here>
WHERE SSUSR_Initials = 'xxxx"Hi,
How to write code in table trigger to send SMS upon any modification on particular column?
Thanks
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 | CT_abc |
| Loc | ID |
| Type |
P: Public Pv: Private C: Community |
| code | CT_loc. |
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.
I'm working in an application that uses %SIMILARITY to find matches among a set of documents that vary greatly in length. It's generally good but I've noticed issues with ranking short partially-matching documents over longer documents that match the search string entirely.
Reading up on the Okapi BM25 ranking function (which is what %SIMILARITY / the %Text package use) at https://en.wikipedia.org/wiki/Okapi_BM25
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
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?
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.
How to implement table splitting in cache
Hello All
I'm running into an issue performing UPDATES that I'm not getting on INSERTS. It's probably obvious, but I'm just not seeing it and could use a little help.
I'm going over an HL7 message and depending upon varying criteria, the relevent variables will get items added to them like the following:
Set patientId = pRequest.GetValueAt("PID:3")
Set sqlColumns = sqlColumns_",patient_id"
Set sqlValues = sqlValues_",?"
Set par($i(p)) = patientIdAfter compiling the variables, I check to see if accession number is found in the table.
set performInsert = 1
set performUpdate = 0
...
set sqlQueryText = "SELECT id FROM table_name WHERE accession_number= ?"
set sc = ..Adapter.ExecuteQuery(.resultSet,sqlQueryText,accessionNumber)
if $$$ISERR(sc) {return sc}
while (resultSet.%Next() '= 0){
Set performUpdate = 1
Set performInsert = 0
}
Set par = pI'm close with this but I'm not sure how to grab JUST the GT1.3 data. I know I can do a substring but finding the 3rd | is a tad tricky. I've not been this deep in SQL for 15 years.
SELECT SUBSTRING(hm.RawContent, (CHARINDEX('GT1',hm.RawContent)), 50) as NameDesc
FROM Ens.MessageHeader as em, EnsLib_HL7.Message as hm
where em.Status = 'Suspended'
and em.MessageBodyId = hm.id
I expect it should flow like this...
SELECT UNIQUE SUBSTRING(RawContent, (FIND 3RD PIPE),(FIND 4TH PIPE) as NameDesc ....
Hello,
I am trying to work out if there are any methods available to be able import a result set returned by SQL query into a persistent class.
I have to connect to some legacy SQL databases through SQL Gateway and run some queries. I need to inster the rows returned into a class to then be able to do a %JSONExport to produce a JSON object. I know I can iterate through the resultset and insert one row at a time into the class but was wondering if there is any other/direct way of importing the resultset rows into a class.
Regards,
Utsavi
I have created a custom role in IRIS for users to provide limited view-only access for querying tables in the HSANALYTICS namespace. WinSQL has been installed on a Windows server (WinSQL Lite version 14.0.244.784) and an ODBC connection entry has been created in WinSQL for the users to log in and run SQL queries. The custom role provides the roles/resources included in the attached file. The WinSQL System DSN entry defined is:
Health Insight UAT HSANALYTICS 64-bit InterSystems ODBC35
The ODBC35 driver is defined as:
InterSystems ODBC35 2018.01.00.184 CACHEODBC3564.
Hi folks!
Here is how I grant SQL access of user to a particular class/table:
GRANT SELECT, UPDATE ON Packacge_X.Table_Y TO UserZHow can I grant SQL access of a certain user to a whole schema?
Hello,
We have a need to track Database changes over time - down to the SQL level of granularity if possible. Such as: User xyz runs routine ^abc and we get something similar to a changelog that tells us: table A had this value updated, insert, update etc....
Is that possible using IRIS level tools (Audit Log, Journal File, etc...) , is there a way to convert the global sets and kills from the journals into SQL level changes?
I also found a third-party java-based tool named Liquibase , but it seems more oriented to tracking schema and table based changes or pre-defined definitions.
Thanks,
James
Hi Community,
Please welcome the new video on InterSystems Developers YouTube: