Find

Article
· Jul 20, 2020 2m read

SPOOL as SQL Table

It is a classic Global Mapping exercise presenting ^SPOOL as Class / Table

Background

Device #2 named SPOOL dates back to the predecessors of Caché and IRIS
It was the first "%Stream" like option to buffer output before printing.
It is also the first and till today the most simple way of output redirection.

Solution

This is also an example of a mapped Global.
USE 2 redirects the output into the Global ^SPOOL

You can read the global manually or with some ancient utilities
or use this mapping to access it as class or a SQL table.

The structure of Spool

  • the global ^SPOOL is local to your namespace
  • fist subscript is a UNIQUE Document_ID
  • second subscript is a line number UNIQUE to the document.
  • both together form the IDkey

Details: The Spool Device

How to use it:

Open a session in your container

 USER>set file="/irisdev/app/lorem.txt" open file:"RS":1 else  write "no file",! quit
 USER>open 2 for i=1:1 u file read line quit:line=""  use 2 write line,!
 USER>close 2 zwrite ^SPOOL
 USER>

Now you can see your SPOOLed text either from SMP or directly from your session

USER>do $system.SQL.Shell()
SQL Command Line Shell
----------------------------------------------------
The command prefix is currently set to: <<nothing>>.
Enter <command>, 'q' to quit, '?' for help.
[SQL]USER>>SELECT TOP 12 ID,* FROM SPOOL
1.      SELECT TOP 12 ID,* FROM SPOOL

ID Document LineNumber Text
1||1 1 1 Lorem ipsum dolor sit amet, consectetuer adipiscing
1||2 1 2 elit, sed diam nonummy nibh euismod tincidunt ut laoreet
1||3 1 3 dolore magna aliquam erat volutpat. Ut wisi enim ad minim
1||4 1 4 veniam, quis nostrud exercitation ulliam corper suscipit lobortis
1||5 1 5 nisl ut aliquip ex ea commodo consequat.
1||6 1 6 Duis autem veleum iriure dolor in hendrerit in vulputate
1||7 1 7 velit esse molestie consequat, vel willum lunombro dolore
1||8 1 8 eu feugiat nulla facilisis
1||9 1 9 at vero eros et accumsan
1||10 1 10 et iusto odio dignissim qui blandit praesent
1||11 1 11 luptatum zzril delenit augue duis dolore te feugait nulla
1||12 1 12 facilisi. Li Europan lingues es membres

12 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0732s/37737/175514/0ms
execute time(s)/globals/cmds/disk: 0.0008s/13/1786/0ms
cached query class: %sqlcq.IRISAPP.cls2

[SQL]USER>>quit
USER>

 

GitHub

Discussion (0)1
Log in or sign up to continue
Article
· Jul 19, 2020 1m read

Organize ZLANG

The guide “Extending Languages with %ZLANG Routines”
Tells you all details you need to know to extend your programming language.
EXCEPT: How to do it in a clean way.

This example of a %ZLANGC00.mac may show a possible approach
to get an easy to overview and to manage setup.
With less than 50 lines of code you might not be affected.
But if your Studio shows close to 1000 rows or more you may get in troubles.

My recommendation is simple.
Instead of adding line-by-line commands and it's code
you isolate each command and its code into a separate Include file.

And what is left in your %ZLANG* Routines is a simple and easy to
overview list of included customized Commands, Functions, Variables
See the details in an example for %ZLANGC00.mac . To prevent conflicts
with the existing %ZLANGC00.mac it is named here ZLANGC00.mac
-------
BTW: #include can do more than just host #define, .. for $$$_references

GitHub

Discussion (0)1
Log in or sign up to continue
Article
· Jul 4, 2020 2m read

Terminal Multi-Line Command Editor

The Command extension enables the execution of Multi-Line Commands from Terminal prompt.

Terminal Multi-Line Input with Edit, Insert, Delete, Print extension for IRIS and Caché
IRIS and Caché have just single command lines in terminal available
This Multi-Line Commands Editor also will execute the Multi-line Commands.
In addition, it is independent of access to %SYS and can be installed in any namespace

Special thanks to @Jeffrey Drumm  who inspired me to this and supported me as beta-tester.

It is tested on IRIS/Caché Terminal , Putty, Linux Console, Docker Console,
Desktop Docker from Windows Command and WebTerminal.

This broad range of terminal emulations required navigation without any <ESC> sequences
as some of them are quite restrictive on input. So it got a little bit feeling like vi.

Installation & Execution

Import ZME.xml to any namespace.

For a system-wide installation in %SYS just rename it from zme to %zme
You may also add this line to your %ZLANGC00.mac for simplified use:

ZME do ^%zme quit  ; add multi line command editor  

Otherwise, just call it from terminal command prompt

  USER>do ^zme  

Usage

at the prompt USER:zme>1
enter commands as usual in terminal
trigger execution by an empty line with

These Editor Commands are implemented:

    USER>d ^zme
 
    Entering multi line mode.
    <enter> => Run multi-line command.
    . => Stop multi-line mode
    .i, .i<line> => Insert new empty line after <line>
    .d, .d<line>, .d<linefrom>:<lineto> => Delete lines
    .p, .p<line>, .p<linefrom>:<lineto> => Show lines
    .? => show this help
    .e, .e<line> => Edit line

    ***** line editing commands *****
    .+ => move edit cursor forward
    .- => move edit cursor backward
    .nn => move edit cursor to position nn
    .r => set mode replace at cursor
    .i => set mode insert after cursor
    .d => delete character at cursor
    <enter> => teminate line editing
    <any character> => replace / insert after cursor
    .. => input single .

    USER:zml>1

GitHub

1 Comment
Discussion (1)0
Log in or sign up to continue
Announcement
· Jun 30, 2020

New Video: Reintroducing the Operational Data Store

Hi Community,

The new video from Global Summit 2019 is available on InterSystems Developers YouTube:

⏯ Reintroducing the Operational Data Store

The Operational Data Store (ODS) is a key feature of our healthcare products that can support your work with FHIR. This video provides an overview of the ODS and highlights its benefits.

Takeaway: You will gain a greater appreciation of how the ODS helps their work with FHIR.

Presenter: @Matt SpielmanManager, Product Management, InterSystems

Additional materials to this video you can find in this InterSystems Online Learning Course.

Enjoy watching this video! 👍🏼

1 Comment
Discussion (1)0
Log in or sign up to continue
Article
· Jun 29, 2020 2m read

ターミナルやAPIを使用してネームスペースやデータベースを作成する方法

Config.Configurationクラス、SYS.Databaseクラスのメソッドを使用して、ネームスペース・データベースの作成及び登録をターミナルから実行することができます。

以下はデータベースファル/CacheDB/AAA/cache.datを作成し、構成ファイル(cache.cpf)にデータベース AAA、及び、ネームスペースAAAの登録を行う一連の実行例です。 *実行は、%SYSネームスペースで行って下さい。*
 

 Set Directory="/CacheDB/AAA/"
 Set x=$ZF(-100, "/shell", "mkdir", Directory)
 Set db=##Class(SYS.Database).%New()
 Set db.Directory=Directory
 Set status=db.%Save()
 Set DBName="AAA"
 Set status=##class(Config.Configuration).AddDatabase(DBName,Directory)
 Set NSName=DBName
 Set status=##class(Config.Configuration).AddNamespace(NSName,DBName)


リモートデータベースからネームスペースを作成する場合は、以下のデータベース定義で、第三パラメータにリモートのサーバ名を指定します。
 

 Set status=##class(Config.Configuration).AddDatabase(DBName,Directory,Server)


※クラスの詳細については、それぞれのクラスリファレンスをご参照下さい。
また、データベースの作成・登録については、^DATABASEルーチンを使用することも可能です。

このルーチンを実行すると、下記のようにオプションが表示されますので、目的によって選択します。
以下は、データベース作成の実行例です。

*実行は、%SYSネームスペースで行って下さい。*
 

%SYS>do ^DATABASE 1) Create a database
2) Edit a database
3) List databases
4) Delete a database
5) Mount a database
6) Dismount a database
7) Compact a database
8) Show free space for a database
9) Show details for a database
10) Recreate a database
11) Manage database encryption
Option? 1
Database directory? D:\200820DS\Mgr\TEST2
Directory does not exist, create it? No => y
Change default database properties? No =>
Dataset name of this database in the configuration: TEST2
Mount TEST2 Required At Startup? No => y
Confirm creation of database in d:\200820ds\mgr\test2\? Yes => y
Formatting...
Database in d:\200820ds\mgr\test2\ created
Dataset TEST2 added to the current configuration.
Database directory?


※^DATABASEルーチンの各オプションについては、以下ドキュメントページをご参照ください。

^DATABASEについて【IRIS】
^DATABASEについて

3 Comments
Discussion (3)2
Log in or sign up to continue