新しい投稿

検索

記事
· 2025年8月21日 4m read

Um guia para iniciantes para criar tabelas SQL e vê-las como classes

O artigo do August Article Bounty sobre Global Masters, e um dos tópicos propostos me pareceu bastante interessante para uso futuro em minhas aulas. Então, é isso que eu gostaria de dizer aos meus alunos sobre tabelas no IRIS e como elas se correlacionam com o modelo de objeto.

Primeiro, o InterSystems IRIS possui um modelo de dados unificado. Isso significa que, ao trabalhar com dados, você não está preso a um único paradigma. Os mesmos dados podem ser acessados e manipulados como uma tabela SQL tradicional, como um objeto nativo, ou até mesmo como um array multidimensional (um global). Isso significa que, ao criar uma tabela SQL, o IRIS cria automaticamente uma classe de objeto correspondente. Ao definir uma classe de objeto, o IRIS a torna automaticamente disponível como uma tabela SQL. Os dados em si são armazenados apenas uma vez no eficiente motor de armazenamento multidimensional do IRIS. O motor SQL e o motor de objeto são simplesmente diferentes "lentes" para visualizar e trabalhar com os mesmos dados.

Primeiro, vamos ver a correlação entre o modelo relacional e o modelo de objeto:

Relacional Objeto
Tabela Classe
Coluna Propriedade
Linha Objeto
Chave primária Identificador de objeto

Nem sempre é uma correlação de 1:1, já que você pode ter várias tabelas representando uma classe, por exemplo. Mas é uma regra geral.

Neste artigo, discutirei a criação de uma tabela listando suas colunas.

A abordagem mais básica:

CREATE TABLE [IF NOT EXISTS] table (
   column1 type1 [NOT NULL], 
   column2 type2 [UNIQUE], 
   column3 type3 [PRIMARY KEY]
   ...
   [CONSTRAINT fKeyName FOREIGN KEY (column) REFERENCES refTable (refColumn)]
)

[ ] designam as partes opcionais.

Vamos criar uma tabela DC.PostType,que consiste em três colunas: TypeID(chave primária), Name, eDescription:

CREATE TABLE DC.PostType (
  TypeID        INT NOT NULL,
  Name          VARCHAR(20), 
  Description   VARCHAR(500),
  CONSTRAINT Type_PK PRIMARY KEY (TypeID)
)

Como resultado, obteremos a seguinte classe após a execução da instrução SQL acima:

/// 
Class DC.PostType Extends %Persistent [ ClassType = persistent, DdlAllowed, Final, Owner = {UnknownUser}, ProcedureBlock, SqlRowIdPrivate, SqlTableName = PostType ]
{

Property TypeID As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ Required, SqlColumnNumber = 2 ];
Property Name As %Library.String(MAXLEN = 20) [ SqlColumnNumber = 3 ];
Property Description As %Library.String(MAXLEN = 500) [ SqlColumnNumber = 4 ];
Parameter USEEXTENTSET = 1;
/// Bitmap Extent Index auto-generated by DDL CREATE TABLE statement.  Do not edit the SqlName of this index.
Index DDLBEIndex [ Extent, SqlName = "%%DDLBEIndex", Type = bitmap ];
/// DDL Primary Key Specification
Index TypePK On TypeID [ PrimaryKey, SqlName = Type_PK, Type = index, Unique ];
Storage Default
{
<Data name="PostTypeDefaultData">
<Value name="1">
<Value>TypeID</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>Description</Value>
</Value>
</Data>
<DataLocation>^B3xx.DXwO.1</DataLocation>
<DefaultData>PostTypeDefaultData</DefaultData>
<ExtentLocation>^B3xx.DXwO</ExtentLocation>
<IdFunction>sequence</IdFunction>
<IdLocation>^B3xx.DXwO.1</IdLocation>
<Index name="DDLBEIndex">
<Location>^B3xx.DXwO.2</Location>
</Index>
<Index name="IDKEY">
<Location>^B3xx.DXwO.1</Location>
</Index>
<Index name="TypePK">
<Location>^B3xx.DXwO.3</Location>
</Index>
<IndexLocation>^B3xx.DXwO.I</IndexLocation>
<StreamLocation>^B3xx.DXwO.S</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}

Principais Observações:

  • TABLE DC.PostType se tornouClass DC.PostType.
  • A classe Extends %Persistent,que é o que informa ao IRIS para armazenar seus dados no banco de dados.
  • VARCHAR se tornou %String.
  • INT se tornou%Integer.
  • A restriçãoPRIMARY KEY criou um Indexcom a palavra-chave PrimaryKey.

Agora você pode usar esta tabela/classe de qualquer lado, por exemplo, usando SQL:

INSERT INTO DC.PostType (TypeID, Name, Description) VALUES (1, 'Question', 'Ask a question from the Community')

Há muito mais sobre a criação de tabelas usando SQL, por favor, leia a documentação fornecida abaixo.

1 Comment
ディスカッション (1)2
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年8月21日

[New DC Feature] Add Documentation Links to Your Articles

Hi Community,

Please welcome a new feature on Developer Community – the ability to add a link to the official InterSystems Documentation directly at the end of your post.

How it works

When publishing an article, paste the relevant URL from docs.intersystems.com into the InterSystems Documentation link field.

Your article will then display a clear callout with the related documentation, making it easier for readers to dive deeper into the topic.

Special thanks to @Luis Angel Pérez Ramos , who suggested this idea via the Ideas portal

You asked – we did it :)

Hope you'll find this feature useful. 

3 Comments
ディスカッション (3)4
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年8月21日

Meetup Brazil - Gen AI e Agentic AI Meetup para Desenvolvedores e Startups

Olá Comunidade! 

Esse ano teremos pela primeira vez o Meetup no Brasil 🇧🇷.

 

O Meetup Brazil será um encontro em📍São Paulo para desenvolvedores e startups explorarem tendências de inteligência artificial, interoperabilidade e orquestração de dados, com foco em conteúdo técnico e networking de qualidade.

Os ingressos são gratuitos. Garanta logo o seu ! 

 

Teremos 2 palestras: 

  • Palestra 1: Assistentes de Programação de IA - por @Fernando Ferreira, Sales Engineer, InterSystems
  • Palestra 2: O Futuro Já Chegou? Uma Nova Era de Interoperabilidade e Orquestração de Dados com RAG e MCP - ​​​​@Claudio Devecchi, Senior Sales Engineer, InterSystems 

Será uma excelente oportunidade para reunirmos essa fantástica Comunidade de Desenvolvedores para trocarmos idéias e experiencias, e comermos uma pizza 🍕 super saborosa para celebrarmos este encontro.

Esperamos por vocês ! 😉

6 Comments
ディスカッション (6)4
続けるにはログインするか新規登録を行ってください
質問
· 2025年8月21日

Reply Action Codes Won't Suspend Message

Hello,

I'm trying to get the Reply Action Code to work with the error message text.

I have this ACK:

MSH|^~\&|APP|FACIL|||20250821143621||ACK|CUEACK_20250821143621|P|2.4
MSA|AE||Failed to queue message

This is some of the Action Codes I've tried:

  • E*Failed to queue message=S
  • E*Failed=S
  • E*"Failed to queue message"=S
  • :E*Failed to queue message=S
  • :?E*Failed to queue message=S

It's not suspending the message however.

What am I doing wrong?

Thank you

2 Comments
ディスカッション (2)2
続けるにはログインするか新規登録を行ってください
記事
· 2025年8月21日 3m read

Migrating InterSystems Studio/Caché and Visual Studio Code Setup to a new Windows PC

Recently, I replaced my old laptop with a new one and had to migrate all my data. I was looking for a guide but couldn’t find anything that explained in detail how to migrate server connections from InterSystems Studio and Visual Studio Code from one PC to another. Simply reinstalling the tools is not enough, and migrating all the connections manually seemed like a waste of time. In the end, I managed to solve the problem, and this article explains how.

InterSystems Studio

Exporting Server Connections

Migrating Studio connections was the most challenging part. Server connections are stored in the Windows Registry, which can be opened from PowerShell by running:

regedit

This allows you to explore all registry keys through a graphical interface.

Depending on the version installed, Studio connections can be found in one of the following locations:

  • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intersystems
  • HKEY_CURRENT_USER\Software\InterSystems\Cache\Servers

In my case, most connections were stored in the second path.

If you browse the Registry Editor, you will find connection information under the Servers folder, with one entry for each connection.

To export all the connections directly from the registry into a file, run this command in PowerShell:

reg export "HKCU\Software\InterSystems\Cache\Servers" "$env:USERPROFILE\Desktop\IRIS_Studio_Connections.reg" /y
  • This creates a .reg file containing all your Studio connections.
  • The file is saved to your Desktop.
  • The /y flag overwrites the file if it already exists.

Importing on the New PC

To import the connections, copy the .reg file to the new PC and run this command in PowerShell:

reg import "C:\Path\To\IRIS_Studio_Connections.reg" 

Alternatively, double-click the .reg file to import it manually.

At this point, InterSystems Studio on your new PC will contain the same server connections you had on the old one.

Note: passwords are not migrated, so you will need to re-enter them the first time you connect.

Visual Studio Code

Exporting Server Connections

Migrating server connections in Visual Studio Code is more straightforward than in Studio since connections are all stored in the settings.json file.

To open it:

  • Click on the InterSystems extension icon in the sidebar
  • Click the three dots icon (“More Actions...”), and select Edit Settings.

  •  Click now on settings.json:

  • All connections are stored under the "intersystems.servers" property of the JSON:

  • Copy these entries and paste them into the settings.json file on the new PC.

Exporting the Whole Profile

Another option is to export your entire VS Code profile.

  • Click on the gear icon in the bottom-left corner.
  • Navigate to Profiles → Profiles.

  • Select the desired profile and choose Export.

  • A code profile file will be generated. 
  • You can copy this file to the new PC and import it into VS Code. From the same Profiles screen, click the arrow next to New Profile, then select Import Profile. This will restore all settings, including server connections.

ディスカッション (0)2
続けるにはログインするか新規登録を行ってください