Nova postagem

Pesquisar

Pergunta
· Mar. 25

Distinct strings in MDX

Hi!

I have question about MDX functionality in context of IRIS Analytics.

How does IRIS MDX distinct selection works? Is there any restruqtion when analyzing strings? Like special symbols or length?

Here is an example

I have this data:

 6 rows and 2 of them unique

Then we create data cube based on this model and examine it with Analyzer

 
Detailed listing
 

6 rows an ONE unique string. Which is obviously not true. 
This happed only with string with symbols in it

My task is to get the right amount of unique strings

2 Comments
Discussão (2)2
Entre ou crie uma conta para continuar
Artigo
· Mar. 25 1min de leitura

ORDER BY で並べ替える際の照合順を調整する

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

SQLでクエリ実行時、ORDER BYで並べ替えをする場合、各RDBMSによって、照合順が異なることがあります。

たとえば、NULLと空文字の混じった文字列のカラムを並べ替える場合、

IRIS SQLでは、既定の照合順は下記のようになりますが、 

NULL, 空文字, 0, 00, 01, 1, 10, 100, 11, A, a, B, b

Oracleでは、下記のような照合順になります。

空文字, 0, 00, 01, 1, 10, 100, 11, A, B, a, b, NULL


複数のDB由来のデータを取り扱う際には、このような照合順の違いを合わせたい場合があります。

IRISの場合、既定の文字列照合はSQLUPPERですが、照合タイプを変更することによって、照合順を変えることが出来ます。

ドキュメント:照合

上記のIRIS SQLとOracleの違いを合わせるためには、照合タイプを「SQLSTRING」に設定し、インデックスを作成します。

Property TestColumn As %String(COLLATION = "SQLSTRING"); 
Index IdxTest On TestColumn;


但し、Nullについてはこの方法では対応できないため、Nullの照合順を合わせたい場合には、ORDER BY句を下記のようにします。

ORDER BY IFNULL(TestColumn, 1, 0), TestColumn
Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· Mar. 25 6min de leitura

%Net.POP3 を使用して添付ファイル付きのメールを受信する方法 --- Gmailを使用したサンプルのご紹介

以前公開している こちら の記事では、「OAuth 2.0 を利用して IRIS から Gmail を送信する」方法をご紹介しています。

本記事では、 %Net.POP3 クラスを使用してメールを受信するサンプルをご紹介します。


【事前準備(Gmailの場合)】

外部アプリからGmailを受信するには OAuth 2.0が必要となるため、こちらの手順 に従ってAccessToken を取得しておきます。
また、「2.【準備】IRIS で、SSLクライアントの設定をする : 手順(4)」の手順に従って、GMAILSSL(任意の名前)の構成を作成しておきます。


【サンプルの内容】

以下のサンプルでは、

1.Gmailの受信サーバ(servername = pop.gmail.com)に、ユーザ名(user = xxx@gmail.com)、パスワード(pass = パスワード)、AccessTokenを使用して接続し、

Set status=server.Connect(servername,user,pass,accesstoken)

2.メールボックスの情報を取得し、

Do ..ShowMailbox(server)

3.Fetch() メソッドを使用して、添付ファイルを含むメールの内容の取得し、
  (添付は server.AttachDir で指定したディレクトリに保存)

Do ..FetchMailbox(server)

4.さらに、メールの内容を表示(出力)しています。

Do DumpMessage(msg)

※3や4の処理は、不要であればコメントアウトして、メールボックスの情報のみ取得することも可能です。
 

【注意】%Net.SMTP と %Net.POP3 の OAuth 対応は、Cache2018.1.8IRIS2021.1.3 以降のバージョンとなります。



【サンプルコード:ObjectScript】

Class User.RecMail Extends %RegisteredObject
{

ClassMethod TestPOP3()
{
  Set server=##class(%Net.POP3).%New()
  set server.SSLConfiguration="GMAILSSL"
  set server.UseSTARTTLS=0
  Set server.port=995
  //Settings for retrieving messages with attachments
  Set server.StoreAttachToFile=1
  Set server.StoreInlineToFile=1
  Set server.AttachDir="C:\temp\"
  Set servername="pop.gmail.com"
  Set user=^user
  Set pass=^pass           // accesstoken を指定する場合は、パスワードは省略可能
  Set accesstoken=^accesstoken
  Set status=server.Connect(servername,user,pass,accesstoken)   // OAuthが必要ない場合、accesstokenは省略可
  If $$$ISERR(status) 
  {
    Do $System.Status.DisplayError(status) 
    Do server.QuitAndRollback()
    Quit
  }
  
  // Getting information about the Mailbox
  Do ..ShowMailbox(server)
  
  // Getting mail contents including attachment files using the Fetch() method
  Do ..FetchMailbox(server)

  Do server.QuitAndCommit()
  Quit
}

/// メールボックスの情報を取得
ClassMethod ShowMailbox(server As %Net.POP3)
{
    Set status=server.GetMailBoxStatus(.count,.size)
    If $$$ISERR(status) {
       Do $System.Status.DisplayError(status) 
       Quit
    }
    Write "Mailbox information(ShowMailbox) *****",!
    Write "Number of messages in mailbox: ",count,!
    Write "Size of messages: ",size,!

    Set status=server.GetMessageUIDArray(,.uids)
    Set status=server.GetSizeOfMessages(,.sizes)
    
    //iterate through messages, get info, and write it
    For i=1:1:count {
        Set uid=uids.GetAt(i)
        Set size=sizes.GetAt(i)
        Write "Msg number:", i,"   UID:",uid, "   size:",size,!
    }
}

/// Fetch() メソッドを使用して、添付ファイルを含むメールの内容の取得
ClassMethod FetchMailbox(server As %Net.POP3)
{
  Set status=server.GetMailBoxStatus(.count,.size)
  If $$$ISERR(status) {
    Do $System.Status.DisplayError(status) 
    Quit
  }
  Write !,"Mailbox information(FetchMailbox) *****",!
  Write "Number of messages in mailbox: ",count,!
  Write "Size of messages: ",size,!

  Set status=server.GetMessageUIDArray(,.uids)
  Set status=server.GetSizeOfMessages(,.sizes)
  
  //iterate through messages, get info, and write it
  For i=1:1:count {
    Set uid=uids.GetAt(i)
    Set size=sizes.GetAt(i)
    Set status=server.Fetch(i,.msg)  // 第3引数に 1 を指定すると、処理後にメッセージを削除する
    If $$$ISERR(status) {
      Do $System.Status.DisplayError(status)
      Set subj="***error***"
      Quit
    } else{
      Set subj=msg.Subject
    }
    Write !,!,"=================================================",!
    Write "Msg number:", i,"  UID:",uid, "  Size:",size
    Write "  Subject: ",subj,!
    Write "From: "_msg.From,!
    Write "Date: "_msg.Date,!
    
    /*--- To view the contents of emails ---*/
    Do ..DumpMessage(msg)

  }
}

/// メールの内容を表示(出力)
ClassMethod DumpMessage(msg As %Net.MailMessagePart)
{
    write "-------------------------",!
    if msg.IsMultiPart {
        for i=1:1:msg.Parts.Count() {
            write !,"[Dumping part "_i,"]",!
            do ..DumpMessage(msg.Parts.GetAt(i))
        }
    } 
    else {
        write "ContentType=",msg.ContentType,!!
        //----- Binary -----
        if msg.IsBinary {
            if msg.FileName="" {
                set stream=msg.BinaryData
                do stream.Rewind()
                for  set len=32763 quit:stream.AtEnd  Write stream.Read(.len)
            } else {              //----------------- Attached File
                write "Attached File Name(Binary):"_msg.FileName,!
            }
        //----- Text -----				
        } else {
            if msg.FileName="" {
                set stream=msg.TextData
                do stream.Rewind()
                for  set len=32763 quit:stream.AtEnd  Write stream.Read(.len)
            } else {              //----------------- Attached File
                write "Attached File Name(Text):"_msg.FileName,!
            }
        }
    }
}

}


どんな出力になるのか、ターミナルで実行したサンプルの出力例をご紹介します。

以下は、2通のメールの受信例で、それぞれテキストとバイナリの添付ファイルを受信しています。

USER>do ##class(User.RecMail).TestPOP3()
Mailbox information *****
Number of messages in mailbox: 2
Size of messages: 29095
Msg number:1   UID:GmailId195cbf0bf4fc2799   size:15195
Msg number:2   UID:GmailId195cbf0fb0ed8cde   size:13900
Mailbox information *****
Number of messages in mailbox: 2
Size of messages: 29095
=================================================
Msg number:1  UID:GmailId195c  Size:15195  Subject: テキストを添付
From: xxx <xxx@InterSystems.com>
Date: Tue, 25 Mar 2025 06:15:02 +0000
-------------------------

[Dumping part 1]
-------------------------
ContentType=text/plain

Start
あいうえお
かきくけこ
さしすせそ
End


[Dumping part 2]
-------------------------
ContentType=text/plain

Attached File Name(Text):note.txt


=================================================
Msg number:2  UID:GmailId195c  Size:13900  Subject: Binaryを添付
From: xxx <xxx@InterSystems.com>
Date: Tue, 25 Mar 2025 06:15:19 +0000
-------------------------

[Dumping part 1]
-------------------------
ContentType=text/plain

Aaaaa
Bbbbb
Ccccc
Ddddd


[Dumping part 2]
-------------------------
ContentType=application/octet-stream

Attached File Name(Binary):test2.csv

USER>


添付ファイルは以下のディレクトリに保存されています。



詳細は以下のドキュメントをご覧ください。
POP3 を介した電子メールの取得

Discussão (0)0
Entre ou crie uma conta para continuar
Pergunta
· Mar. 25

AWS Files

Hi Guys,

I'm looking to create a service to download files from S3, so I used the EnsLib.AmazonS3.BusinessService with settings as below to download files that starts with SMfile_48 but I'm not getting any files, am I missing something?

 

 

 

Thanks

1 Comment
Discussão (1)1
Entre ou crie uma conta para continuar
Anúncio
· Mar. 24

Reminder: Beta Testers Needed for Our Upcoming InterSystems IRIS Developer Professional Certification Exam

Hello again IRIS community,

We have officially released our InterSystems IRIS Developer Professional certification exam for beta testing. The beta test will be available until April 20, 2025. As a beta tester, you have the chance to earn the certification for free!

Interested in beta testing? See the InterSystems IRIS Developer Professional Beta Test Developer Community post for exam details, recommended preparation, and instructions on how to schedule and take the beta exam. 

Thank you!

Discussão (0)1
Entre ou crie uma conta para continuar