Rechercher

記事
· 2025年9月4日 2m read

Vincular tabelas programaticamente

Rubrica InterSystems FAQ

No InterSystems IRIS, você pode criar tabelas vinculadas usando comandos, ao invés de usar o caminho System Explorer > SQL > Wizard > Linked Tables do Portal de Administração:

Para criar uma tabela vinculada, use o método CreateLinkedTable da classe  %SYSTEM.SQL.Schema. Veja a documentação da classe para detalhes.

Para executar, siga os passos:

set sc = $SYSTEM.SQL.Schema.CreateLinkedTable("<dsn>","<Schema>","<Table>","<primaryKeys>","<localClass>","<localTable>","")

/// 1st argument: dsn - SQL Gateway connection name
/// 2nd argument: Schema - Source schema name
/// 3rd argument: Table - Source table name
/// 4th argument: primaryKeys - Primary key
/// 5th argument: localClass - Linked class name (e.g., User.LinkedClass)
/// 6th argument: localTable - Linked SQL table name (SqlTableName)
/// 7th argument: columnMap - Linked field information

Se você executar o código dessa maneira, a tabela vinculada será criada com o atributo ReadOnly. Se quiser removê-lo, é necessário especificá-lo no sétimo argumento, columnMap.

set columnMap("external field name") = $lb("new class property name","new sql field name","read-only(1/0)")

Nessa amostra, um columnMap é criado, definindo ReadOnly como 0 para todos os campos (colunas), e uma tabela vinculada é criada. A primaryKey é definida para herdar a primaryKey da tabela vinculada. O uso é como a seguir:

do ##class(ISC.LinkUtils).LinkTable("<dsn>","<Schema>","<Table>","<localClass>")

/// First argument: dsn - SQL Gateway connection name
/// Second argument: Schema - Link source schema name
/// Third argument: Table - Link source table name
/// Fourth argument: localClass - Link destination class name (e.g., User.LinkedClass)

Você também pode ver o exemplo usado aqui: https://github.com/Intersystems-jp/CreateLinkedTable

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

Link tables programmatically

InterSystems FAQ rubric

In InterSystems IRIS, you can create linked tables using commands, instead of using System Explorer > SQL > Wizard > Linked Tables in the Management Portal:

To create a linked table, use the CreateLinkedTable method of the %SYSTEM.SQL.Schema class. See the class reference for details.

To execute it, follow these steps:

set sc = $SYSTEM.SQL.Schema.CreateLinkedTable("<dsn>","<Schema>","<Table>","<primaryKeys>","<localClass>","<localTable>","")

/// 1st argument: dsn - SQL Gateway connection name
/// 2nd argument: Schema - Source schema name
/// 3rd argument: Table - Source table name
/// 4th argument: primaryKeys - Primary key
/// 5th argument: localClass - Linked class name (e.g., User.LinkedClass)
/// 6th argument: localTable - Linked SQL table name (SqlTableName)
/// 7th argument: columnMap - Linked field information

If you run it this way, the linked table will be created with the ReadOnly attribute. If you want to remove the ReadOnly attribute, you need to specify it in the seventh argument, columnMap.

set columnMap("external field name") = $lb("new class property name","new sql field name","read-only(1/0)")

In this  sample, a columnMap is created that sets ReadOnly to 0 for all fields (columns), and a linked table is created. The primaryKey is set to inherit the primaryKey of the linked table. The usage is as follows:

do ##class(ISC.LinkUtils).LinkTable("<dsn>","<Schema>","<Table>","<localClass>")

/// First argument: dsn - SQL Gateway connection name
/// Second argument: Schema - Link source schema name
/// Third argument: Table - Link source table name
/// Fourth argument: localClass - Link destination class name (e.g., User.LinkedClass)

You can also see the sample used here: https://github.com/Intersystems-jp/CreateLinkedTable

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

About %Stream.TmpCharacter

Dear, Community!

I have a concern about using %Stream.TmpCharacter for storage purposes. Reading the class's source code, I can understand a bit about how it works. But I'd like to know from the community how it actually works. Is it necessary to use the .Clear() method to clear this buffer, or is it done automatically upon disposal?

Note: Please forgive my poor English.

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

Last chance to cast your vote in the InterSystems Demo Games!

Dear Community Member,

We’re entering the final stretch of the InterSystems Demo Games voting period! You’ve seen how our Sales Engineers bring InterSystems technologies to life through creative demos. At this time, all the demos are in. Now it’s time to make your voice heard!

👉 How to vote:

  1. Watch the demos on the Demo Games Contest Page.
  2. Select your favorite entries before September 14, 2025.

Your vote will decide the winners, so don’t miss the chance to support the demos that inspired you the most.

🔗 Full contest details here

Thank you for being part of the Demo Games — and may the best demo win! 🏆

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