Nova postagem

Pesquisar

Artigo
· jan 7 4min de leitura

Obtened vuestro código a través de ODBC/JDBC.

Recientemente me encontré con un problema muy antiguo relacionado con el mantenimiento de código:

Tenéis acceso a vuestro servidor IRIS solo a través de ODBC/JDBC:

  • Sin acceso a VSCode
  • Sin acceso a Studio
  • Sin acceso a (Web-)Terminal

¡Pero necesitáis revisar Clases, Rutinas o Globals!

De cualquier forma, SQL es vuestro aliado.

  • Primero, necesitáis una tabla sencilla como almacén temporal de texto.
CREATE GLOBAL TEMPORARY TABLE  arcc.txt (line VARCHAR(32000))
  • A continuación, exportad vuestro código a un archivo local e importadlo a vuestra tabla.
CREATE PROCEDURE arcc.show (IN code VARCHAR()) 
  RETURNS INTEGER
  LANGUAGE OBJECTSCRIPT 
 {
	set file="code.tmp"
	do $system.OBJ.ExportUDL($g(code),file) 
	open file:"R":0 else  quit 0
	kill ^||arcc.txtD 
	use file
	try { 
		for i=1:1 read line set ^||arcc.txtD($i(^||arcc.txtD))=$lb(line) 
	} 
	catch (e) { 
	   close file:"D"
	}
	quit 1
}

Cómo usarla:

select * from arcc.txt where 1=arcc.show('arcc.txt.cls')

Y obtendréis...

Class arcc.txt Extends %Persistent [ ClassType = persistent, DdlAllowed, Final, Owner = {_PUBLIC}, ProcedureBlock, SqlRowIdPrivate, SqlTableName = txt ]
{
Property line As %Library.String(MAXLEN = 32000) [ SqlColumnNumber = 2 ];
Parameter SQLTABLETYPE = "GLOBAL TEMPORARY";
Storage Default
{
<Data name="txtDefaultData">
<Value name="1">
<Value>line</Value>
</Value>
</Data>
<DataLocation>^||arcc.txtD</DataLocation>
<DefaultData>txtDefaultData</DefaultData>
<IdLocation>^||arcc.txtD</IdLocation>
<IndexLocation>^||arcc.txt</IndexLocation>
<StreamLocation>^||arcc.txt</StreamLocation>
<Type>%Storage.Persistent</Type>
}
}
 
  • O, de forma tradicional, si preferís la salida en XML en lugar de UDL, utilizad
  • $system.OBJ.Export() como método de exportación.
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="IRIS" version="26" zv="IRIS for Windows (x86-64) 2024.2.0L (Build 213U)" ts="2024-12-22 20:40:09">
<Class name="arcc.txt">
<Description>
</Description>
<Final>1</Final>
<ClassType>persistent</ClassType>
<DdlAllowed>1</DdlAllowed>
<Owner>_PUBLIC</Owner>
<ProcedureBlock>1</ProcedureBlock>
<SqlRowIdPrivate>1</SqlRowIdPrivate>
<SqlTableName>txt</SqlTableName>
<Super>%Persistent</Super>
<TimeChanged>67196,63061.387736</TimeChanged>
<TimeCreated>67196,63061.3543687</TimeCreated>
 
<Property name="line">
<Type>%Library.String</Type>
<Collection/>
<Required>0</Required>
<SqlColumnNumber>2</SqlColumnNumber>
<Parameter name="MAXLEN" value="32000"/>
</Property>
 
<Parameter name="SQLTABLETYPE">
<Default>GLOBAL TEMPORARY</Default>
</Parameter>
 
<Storage name="Default">
<Type>%Storage.Persistent</Type>
<DataLocation>^||arcc.txtD</DataLocation>
<DefaultData>txtDefaultData</DefaultData>
<IdLocation>^||arcc.txtD</IdLocation>
<IndexLocation>^||arcc.txt</IndexLocation>
<StreamLocation>^||arcc.txt</StreamLocation>
<Data name="txtDefaultData">
<Structure>listnode</Structure>
<Subscript/>
<Value name="1">
<Value>line</Value>
</Value>
</Data>
</Storage>
</Class>
</Export>

XML puede ser útil para las exportaciones globales si es necesario.

select * from arcc.txt where 1=arcc.showxml('%ZPM.Client.ServerDefD.GBL')
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="IRIS" version="26" zv="IRIS for Windows (x86-64) 2024.2.0L (Build 213U)" ts="2024-12-22 20:50:01">
<Global>
<Node><Sub>^%ZPM.Client.ServerDefD</Sub>
<Data>1</Data>
<Node><Sub>1</Sub>
<DataBase64>NQF+JVpQTS5QYWNrYWdlTWFuYWdlci5DbGllbnQuUmVtb3RlU2VydmVyRGVmaW5pdGlvbn4KAXJl
Z2lzdHJ5AQEBAQMEAQEnAWh0dHBzOi8vcG0uY29tbXVuaXR5LmludGVyc3lzdGVtcy5jb20DBAED
BAECBA==
</DataBase64>
<Node><Sub>RemoteServerDefinition</Sub>
<DataBase64>AQIBAgEnAWh0dHBzOi8vcG0uY29tbXVuaXR5LmludGVyc3lzdGVtcy5jb20CAQIB
</DataBase64>
</Node>
</Node>
</Node>
</Global>
</Export>

Y todo esto sólo se ejecuta sobre ODBC/JDBC

Discussão (0)1
Entre ou crie uma conta para continuar
Resumo
· jan 7

InterSystems Community Annual Newsletter 2024

Hello and welcome to the Developer Community 2024 Annual Newsletter.
General Stats:
3,294 posts published in 2024:
  – 1344 articles
  – 909 announcements
  – 1000 questions
  – 41 discussions
4,616 members joined the Developer Community in 2024
22,319 posts published in total
14,662 members joined in total
Most Popular:
806
By Keren Skubach
Most Discussed
Most Liked
Most popular authors
Authors with the most articles
2024 at a GlanceInterSystems Developer Community
Artigo
· jan 6 1min de leitura

日本のMacユーザーがIRISを使う際にまずやるべきこと

日本でMacユーザーのIRIS使いがどの程度いるのかわかりませんが、圧倒的少数派なのは確かでしょう。

そのせいもあってか、Mac版のインストーラは、Windows版ほどきめ細かい対応をしてくれていません。

Windows版はインストーラが勝手に日本語のロケールを設定してくれているのですが、Mac版(おそらくLinux版も)は英語ロケールのままです。

それでも、通常の使用ではさほど問題がないといえないこともないのですが、ファイルを読んだりする場合や他にも何かと不都合があります。(何かあったような気がしますが、忘れました。)

ですので、Macユーザーは面倒ですが、管理ポータルで日本語ロケールjpuwのインストールをする必要があります。

またはターミナルでコマンド一発でもOKです。

Do ##class(Config.NLS.Locales).Install("jpuw")

ちなみにこのロケールjpuwは説明を読むとUNIX用と書いていますが、WindowsでもファイルI/OなどのデフォルトエンコーディグをSJISではなくUTF8にしたい場合にも使えます。

昨今は、WindowsといえどもUTF8でファイル作成するケースが増えていますので、今更SJISいらないという人は、思い切ってこのロケールに切り替えるというのもありです。

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

获得 InterSystems 技术认证

certification badge

借助 InterSystems 行业标准认证考试,您和您的团队可以获得认证,以验证您的技能并证明您拥有 InterSystems 技术方面的专业知识。 查找适合您的角色的考试!

Discussão (0)0
Entre ou crie uma conta para continuar
Artigo
· jan 6 2min de leitura

JSON文字からダイナミックオブジェクトを作成する際、エラー #5035: 一般例外 名前 'Premature end of data'エラーが出る

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

POST要求で受信したBodyのJSON文字列を、REST ディスパッチクラス内メソッドでダイナミックオブジェクト(%DyamicObject)に変換する際、以下エラーが発生する場合があります。

{
    "errors": [
        {
            "code": 5035,
            "domain": "%ObjectErrors",
            "error": "エラー #5035: 一般例外 名前 'Premature end of data' コード '12' データ ''",
            "id": "GeneralException",
            "params": [
                "Premature end of data",
                12,
                ""
            ]
        }
    ],
    "summary": "エラー #5035: 一般例外 名前 &#39;Premature end of data&#39; コード &#39;12&#39; データ &#39;&#39;"
}

POST要求時に送付するBodyの中身は、RESTディスパッチクラスの中では %request.Content を使用して操作でき、%request.Content.Read()とした場合、JSON文字列が取り出せます。

%request.Content.Read()の結果(=POST要求で受信したBodyの長さ)が32KBを超える場合、Read()メソッドは先頭32KBまでしか読み取らない制限があるため、すべてのJSON文字列が渡らずに上記エラーが発生します。

メモ:変数%requestは%CSP.Requestクラスのインスタンス

JSON文字からダイナミックオブジェクトに変換する際使用する%FromJSON()メソッドの引数には、JSON文字列かJSON文字列が含まれるストリームを指定することができます。

Read()メソッドは先頭32KBまでしか読み取らない制限があるので、以下の例のようにRead()の結果を渡すのではなく

set bodyjson={}.%FromJSON(%request.Content.Read())

JSON文字を含むストリームを%FromJSON()に渡す以下例の方法を使用することで、32KBを超えるJSON文字列が含まれていたとしても、エラーなくダイナミックオブジェクトに変換できます。

set bodyjson={}.%FromJSON(%request.Content)
Discussão (0)1
Entre ou crie uma conta para continuar