SQL

Syndicate content 30 

In addition to its general security, Caché offers SQL security with a granularity of a single row. This is called row-level security. With row-level security, each row holds a list of authorized viewers, which can be either users or roles. By default access is determined at object modification Some time ago I became interested in determining row-level security at runtime. Here's how to implement it.

Last comment 16 June 2017
+ 1   0 5
323

views

+ 1

rating

Whenever I try to run a simple query on a production database table, I get a timeout 504 error. I'm using the SQL interface in Ensemble. One of the queries is a simple SELECT TOP 10. Even SELECT COUNT(*) gives a timeout. 

I have tried to run the SQL Runtime Statistics, but this gives me a timeout as well. 

Does anyone have an idea where I might look to find what is causing this? 

 

Thanks in advance, 

Best regards

Glenn van Bavel, 

 

 

Last answer 15 June 2017
0   0 5
0

comments

651

views

0

rating

This is a translation of the following article. Thanks [@Evgeny Shvarov] for the help in translation.

Someone posted a question on DC asking whether it was possible to determine access rights for a particular table row always at runtime, and if it was, how could one do that?
Answer: it is possible and it’s not hard at all.

Last comment 14 June 2017
+ 3   0 3
304

views

+ 3

rating

I am inserting rows in a table. This table is appearing in all namespace as I did global mapping. 

So once I run insert command from a method, it insert the rows. When I run the same insert command from other namespace, it replace the existing data in table. 

Insert command is same in all namespace but the data I m inserting is different. 

 

0   0 3
0

comments

271

views

0

rating

The Data Platforms department here at InterSystems is gearing up for this year's crop of interns, and I for one am very excited to meet them all next week!

We've got folks from top technical colleges with diverse specialties from hard core engineers to pure computer scientists to mathematicians to business professionals. They come from countries around the world like Vietnam, China, and Finland and they all come with impressive backgrounds. We're sure they will do very well this summer.

+ 6   0 3
0

comments

317

views

+ 6

rating

The Art of Mapping Globals to Classes  (2 of 3)

 

If you are looking to breathe new life into an old MUMPS application follow these steps to map your globals to classes and expose all that beautiful data to Objects and SQL.

 

This example is going to cram in 4 or 5 different things beyond what was covered in Part 1 

Last comment 23 May 2017
+ 10   0 6
1299

views

+ 10

rating

Atelier Users:

Has anyone found an Eclipse plug-in that provides the capability to connect to a Caché server and give the user a way to write SQL queries using the tables from that server? I'm picturing something like a "WinSQL"-client built as an Eclipse plugin.

I've found and tried the following, but I couldn't get it to connect to my local Caché instance.

http://eclipsesql.sourceforge.net/

Last answer 20 April 2017
+ 2   0 0
0

comments

578

views

+ 2

rating

Hi All -

I was wondering if the below query could be enhanced to automatically look back 24 hours from the current datetime the query is run. As is now I, of course, have to update the date range in the WHERE clause manually.

The query is just getting all MessageBodyClassNames, counting them and then doing an AVG on TimeCreated and TimeProcessed. Nothing too complex.

 

SELECT MessageBodyClassName, count(ID) as Count_Of_Messages, avg(datediff(ss, TimeCreated, TimeProcessed)) as avg_processing_time_in_seconds

FROM %PARALLEL Ens.MessageHeader

Last answer 20 April 2017
0   0 2
0

comments

1813

views

0

rating

Hi All,

I use SQL function JSON_OBJECT to get data as a JSON object.

However, sometimes I get error with function JSON_OBJECT when values contain [, ], { or }.

Error:

[SQLCODE: <-400>:<Fatal error occurred>]

Unexpected error occurred in JSON_OBJECT() function execution of <JSON_OBJECT>.%FromJSON().Parsing error

For example,

Query: SELECT JSON_OBJECT('idSQL':id, 'content':content) FROM DocBook.block

0   0 0
884

views

0

rating

 It's almost time to get your customers upgraded to new versions - are you worried about showing off your SQL Performance after upgrades?  If you want to upgrade without worrying, then I have just the program for you!!!  Check out this video from Global Summit 2016 featuring yours truly explaining how to upgrade a system without worrying about pesky SQL queries showing on your waistline!  

https://www.youtube.com/watch?v=GfFPYfIoR_g

0   0 2
0

comments

160

views

0

rating

I'm moving *D globals from DatabaseA to DatabalseB.

After importing globals I need to rebuild indices for all the imported persistent classes.

Colleagues, maybe you know one command which does it for all the classes in Namespace?

Last answer 1 April 2017 Last comment 2 April 2017
0   0 3
398

views

0

rating

Hello, we have a few hundreds of triggers to port from Oracle to Cachè for a migration project, and many of them have to change (for example, normalize a value, null it, etc) the value which is being inserted.

The documentation says "You cannot set {fieldname*N} in trigger code." , so we're unlucky.

Is there a good workaround for this ?

SqlComputeOnChange doesn't seem the best way, but I'm not totally sure: for example normalization and validation could have a better place somewhere else than a trigger.

Last answer 2 April 2017
+ 1   0 1
0

comments

185

views

+ 1

rating

I am trying to return the maximum of the value of 2 fields: LastViewed and LastDownloaded  AS a local variable -LastAccessed for each row, using a SQL query . These values are stored as $ H format.  Is there an existing SQL command that compares two column values ? I could not find one, so I tried using a $Select statement . I got an error that said A term expected beginning with either of: identifier, constant, aggregate, $$,(,:,+....)

Here is the SQL Query I am trying to run:-

Last answer 20 March 2017
0   0 2
0

comments

441

views

0

rating

Overview

Encryption of sensitive data becomes more and more important for applications. For example patient names, SSN, address-data or credit card-numbers etc..

Cache supports different flavors of encryption. Block-level database encryption and data-element encryption. The block-level database encryption protects an entire database.  The decryption/encryption is done when a block is written/read to or from the database and has very little impact on the performance.

With data-element encryption only certain data-fields are encrypted.  Fields that contain sensitive data like patient data or credit-card numbers. Data-element encryption is also useful if a re-encryption is required periodically. With data-element encryption it is the responsibility of the application to encrypt/decrypt the data.

Both encryption methods leverage the managed key encryption infrastructure of Caché.

The following article describes a sample use-case where data-element encryption is used to encrypt person data.  

But what if you have hundreds of thousands of records with an encrypted datafield and you have the need to search that field? Decryption of the field-values prior to the search is not an option. What about indices?

This article describes a possible solution and develops step-by-step a small example how you can use SQL and indices to search encrypted fields. 

Last comment 16 March 2017
+ 4   0 1
915

views

+ 4

rating

I have been following the online Zen Quickstart Tutorial using the lastest release documentation. In addition to playing around with the styling and making a few minor functionality tweaks, I wanted to add an additional column that shows a count of the number of phone numbers for that Contact (as shown in the image below).

Last answer 28 February 2017 Last comment 15 March 2017
0   0 1
255

views

0

rating

I have a tablePane ZEN Component and I am trying to get a filter running on the Specimen Id / Lab Number. The SQL is fairly complex with 3 UNION ALL statements joining 4 tables and a couple of lookup tables.

How would I get the filter on SpecId to work for my tablePane? It's not automatically applying the filter for me so I think I need code something.

Last answer 15 March 2017
0   0 1
0

comments

206

views

0

rating

I use the HS_IHE_ATNA_Repository.Aggregation table a lot.  Someone just referred me to the HS_IHE_ATNA_Repository.Document table, which has an AggregationId column.  

I assume that column references the ID column in the .Aggregation table.  If so, does this mean that if the same document was requested 1,000 times that there will be 1,000 entries for it in the .Document table?  This seems inefficient to me.  Why not have one record in the document table and have a DocumentId column in the Aggregation table?

Last answer 15 February 2017 Last comment 16 February 2017
0   0 2
214

views

0

rating

We've been noticing that we're getting this (https://community.intersystems.com/post/cach%C3%A9-sql-error-odbc) error more frequently and having to constantly purge cached queries in order to resolve it. Is there a way to avoid the issue in the first place?

 

thanks!

Last answer 30 January 2017 Last comment 14 February 2017
0   0 2
245

views

0

rating

I have the following query which tells me how many documents were retrieved for each customer, but it only works for the "on-demand" customers:

SELECT PatientFacility, LEFT(LocalDateTime,7) as Mnth, Count(*)
FROM HS_IHE_ATNA_Repository.Aggregation
WHERE EventType IN ('RecordRequest','RecordRequestBreakGlass')
AND LocalDateTime >= '2016-01-01'
AND LocalDateTime < '2017-01-01'
GROUP BY PatientFacility, LEFT(LocalDateTime,7)

 

Last answer 7 February 2017 Last comment 7 February 2017
0   0 2
218

views

0

rating

I want to override getter for a serial property as a whole, because getter code depends on a class in which a property is defined.

Let's say I have CS.Serial as a serial class:

Class CS.Serial Extends %SerialObject
{
Property Year As %Integer;

Property Month As %Integer;
}

And CS.Persistent as a persistent class:

Last answer 2 February 2017 Last comment 2 February 2017
0   0 0
339

views

0

rating

So I know it's been a while, and I hate to let my adoring fans down... just not enough to actually start writing again.  But the wait is over and I'm back!  Now bask in my beautiful ginger words!

For this series, I am going to look at some common problems we see in the WRC and discuss some common solutions.  Of course, even if you find a solution here, you are always welcome to call in and expression you gratitude, or just hear my voice!

This week's common problem: "My query returns no data."

Last comment 16 January 2017
+ 7   0 2
314

views

+ 7

rating

When working with a large query executed though an ODBC connection what is the best way to allow the paging of the results at the client side.  I have tried some methods using %VID and similar methods, but these really don't seem to work as the value returned is related to the ID of the data and not the position in the results set.  What would be ideal is if the value seen in the management portal when you check of "Row Number" was available to external queries through ODBC.  I have not seen a way to return this however.

Last answer 10 January 2017 Last comment 9 January 2017
0   0 1
491

views

0

rating