Find

Question
· Mar 4

Message Count

Looking for a SQL query or any other method to find the Unique/distinct message counts for all productions or at least per production namespace within a given time frame. For e.g TimeCreated = January 2025 (Whole month)

I have used the following, but its not restricting the numbers based on the TimeCreated filter. Every time a new message is processed by system, its added to the total. I am running the query in today's date

Select Sum(MsgCount)

From

(Select DISTINCT TargetConfigName, count(DISTINCT SessionID) as MsgCount

FROM ENS.MessageHeader 

Where TimeCreated >='2025-01-01 00:00:00' and TimeCreated<='2025-01-31 23:59:59'

Group By TargetConfigName) as Table

12 Comments
Discussion (12)3
Log in or sign up to continue
Article
· Mar 4 4m read

計算プロパティの使用方法2

これは InterSystems FAQ サイトの記事です。
 

計算プロパティを定義する際に利用可能なキーワードが複数あります。

詳細は、以下をご参照ください。

計算プロパティの定義

実際のこれらのキーワードの関連性は、少々複雑ですので具体的なコードを作成して動作を確認してみます。 

以下のようなクラス定義を作成します。(プロパティとインデックス定義のみ表示します)

完全なクラス定義は以下より、ダウンロードできます。

サンプルクラス定義

Class Sample.Person Extends %Persistent [ ClassType = persistent, ProcedureBlock ]

{

Property FirstName As %String;
Property LastName As %String;
Property DOB As %Date;
Property Age1 As %Integer [ Calculated, SqlComputed, Transient ];
Property Age2 As %Integer [ Calculated, Transient ];
Property Age3 As %Integer [ Calculated, SqlComputed ];
Property Age4 As %Integer [ Calculated ];
Property Age5 As %Integer [ SqlComputed, Transient ];
Property Age6 As %Integer [ Transient ];
Property Age7 As %Integer [ SqlComputed ];
Property Age8 As %Integer [ SqlComputed, SqlComputeOnChange = DOB ];
// インデックスは、Trancient = true の時には作れない
// Index IndexAge1 on Age1;
// Index IndexAge2 on Age2;
// Index IndexAge5 on Age5;
// Index IndexAge6 on Age6;
Index IndexAge3 On Age3;
// インデックスは、SqlComputed = false の時には作れない
// Index IndexAge4 On Age4;
Index IndexAge7 On Age7;
Index IndexAge8 On Age8;
}

計算プロパティとしてAge(年齢)というプロパティを作ります。

年齢は、今日の日付から誕生日(DOB)を引き算して経過日数を求め、閏年を考慮しつつ年の日数で割り算することで求められます。

以下にキーワードの組み合わせによる違いについて表にまとめています。

 

同じような年齢プロパティがこれらのキーワードの組み合わせに基づき、8個定義されています。

計算プロパティは、このキーワードの組み合わせによりインデックスを設定できる場合があります。

そして上のコードのコメントに書いてあるとおり Trancient = trueおよびSqlComputed = falseが設定されているとインデックスを作ることができません。 従ってこのサンプルでは、Age3, Age7, Age8のみがインデックス作成可能です。

またAge1とAge2はインデックスが作成できない点で共通で、違いはSqlComputedの指定だけですが、結果がどのように計算されるかについて大きな違いがあります。

それではその計算がどの様にどのタイミングで行われるかを示すサンプルコードを実行してみます。

上のコードに予め含めておいたクラスメソッドを実行することで動作を確かめてみます。

USER>do ##class(Sample.Person).CalculatedPropertyTest()

^Sample.PersonD=1
^Sample.PersonD(1)=$lb("","Kaoru","Shinuchi",60000,18,18)

^Sample.PersonI("IndexAge3",18,1)=""
^Sample.PersonI("IndexAge7",18,1)=""
^Sample.PersonI("IndexAge8",18,1)=""
ID Age1 Age3 Age5 Age7 Age8 DOB FirstName LastName

1 18 18 18 18 18 60000 Kaoru Shinuchi

1 Rows(s) Affected^Sample.PersonD=1
^Sample.PersonD(1)=$lb("","Kaoru","Shinuchi",50000,18,46)

^Sample.PersonI("IndexAge3",46,1)=""
^Sample.PersonI("IndexAge7",18,1)=""
^Sample.PersonI("IndexAge8",46,1)=""
ID Age1 Age3 Age5 Age7 Age8 DOB FirstName LastName

1 46 46 46 18 46 50000 Kaoru Shinuchi

1 Rows(s) Affected

Age1の場合、このキーワードの組み合わせでは、プロパティの計算タイプは常に計算になります。

そしてTrancientなのでデータの実体は持ちません

Age2の場合、プロパティの計算タイプは、計算されないになります。そしてTrancientなのでデータの実体は持ちません。

さらにsqlComputedがFalseなのでSQLのフィールドとしても認識されません。

(但し、このサンプルコードでは示していませんが、クラスインスタンスの計算プロパティとしてはデータ取得可能です。)

Age3の場合、プロパティの計算タイプは、常に計算になります。

データの実体は持たず、その計算結果に基づきインデックスを生成します。

そしてデータが更新された場合にもその更新内容に基づきインデックスも更新されます。

Age4, 6はAge2と同様です。

Age5は、Age1と同じです。 

Age7の場合、プロパティの計算タイプは、トリガーによって計算になります。

しかし、SqlComputeOnChangeが定義されていないので、DOBが変更されてもその変更が検知できずに初回に設定された値をずっと保持したままです。

Age8の場合、プロパティの計算タイプは、トリガーによって計算になります。

ここでは、SqlComputeOnChangeが定義されているので、DOBが変更されるとその変更に基づきAgeが再計算されます。

Discussion (0)1
Log in or sign up to continue
InterSystems Official
· Mar 3

InterSystems Language Server 2.7 的最新变化

首先,祝开发者社区的各位成员新年快乐! 我们希望今年为大家带来更多好东西,今天我想介绍 VS Code的最新版 Intersystems Language Server 扩展程序。 大多数 Language Server 改进都可以通过 ObjectScript 扩展 UI 体验到,因此您可能不知道 2024 年我们发布了 Intellisense 和鼠标悬停等方面的许多改进。 请快速浏览 Language Server 更新日志 看看您错过了什么。 最近发布的2.7.0 版本带来了对 Windows ARM 平台的支持,因此,如果您使用 Surface Pro 11 这类设备(我正在用这台设备愉快地写这篇帖子),那么您现在可以在您的设备上获得出色的 ObjectScript 开发体验。 赶快试用一下,并在下方评论区中分享您的使用心得。

Discussion (0)0
Log in or sign up to continue
Question
· Mar 3

<class 'ImportError'>: Unable to import required dependencies: numpy: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy so

I have pandas installed inside my C:/InterSystems/IRISHealth/mgr/python

 

Set pandas=##class(%SYS.Python).Import("pandas")                        
SET pandas=##CLASS(%SYS.Python).Import("pandas")
^
<THROW> *%Exception.PythonException <THROW> 230 ^^0^SET pandas=##CLASS(%SYS.Python).Import("pandas") <class 'ImportError'>: Unable to import required dependencies:
   numpy: Error importing numpy: you should not try to import numpy from
                                                                                its source directory; please exit the numpy source tree, and relaunch
                                                                             your python interpreter from there. - Import

1 Comment
Discussion (1)1
Log in or sign up to continue
Announcement
· Mar 3

Developing with InterSystems Objects and SQL – In Person (Boston, MA) March 24-28, 2025 / Registration space available

Developing with InterSystems Objects and SQL – In Person (Boston, MA) March 24-28, 2025

  • This 5-day course teaches programmers how to use the tools and techniques within the InterSystems® development environment.
  • Students develop a database application using object-oriented design, building different types of IRIS classes.
    • They learn how to store and retrieve data using Objects or SQL, and decide which approach is best for different use cases.
    • They write code using ObjectScript, Python, and SQL, with most exercises offering the choice between ObjectScript and Python, and some exercises requiring a specific language.
  • This course is applicable for users of InterSystems IRIS® data platform and InterSystems Caché®
  • Self-Register Here
Discussion (0)1
Log in or sign up to continue