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