Nova postagem

検索

Artigo
· jan 25 2min de leitura

How to customize SQL table and field names of classes in InterSystems IRIS

In InterSystems IRIS, when you compile a persistent class, you automatically get a SQL table. Sometimes, there are situations that require having a slightly (or not so slightly) different names/options in SQL compared to Object model. Here are some of the settings that you can change to make it happen.

Class-level settings 

They define the "Face" of your class when it appears as a table in the SQL catalog.

SqlTableName allows you to change the name of SQL table that holds objects from your class. This is especially useful, when your class name uses reserved SQL words in a name, e.g. Group.

Usage:

Class Banking.Group Extends %Persistent [ SqlTableName = Banking_Group ]
{ 

}

SqlRowIdName allows you to rename the default primary key column to something semantically meaningful. Every persistent class has a unique identifier, and by default it's called ID. Naming it PatientID or OrderID makes it much more readable and prevents naming collisions in complex queries.

Usage:

Class Banking.Account Extends %Persistent [ SqlRowIdName = AccID ]
{
    
}

DdlAllowed allows or prevents the table schema from being changed using SQL. For example, if you are a "Class-first" developer, you don't want a DBA accidentally running ALTER TABLE and desyncing the class definition. Setting this to Not DdlAllowed (default) ensures the Class is the "source of truth." Setting it to DdlAllowed allows standard SQL DDL commands to modify the class.

Usage:

Class Banking.Transaction Extends %Persistent [ DdlAllowed ]
{
    
}
Class Banking.Account Extends %Persistent [ Not DdlAllowed ]
{
    
}

Property-level settings

These parameters change how individual data points (properties) are projected as columns.

SqlFieldName allows to provide a different column name than the property name. 

Usage:

Property CurrentAmount As %Float [ SqlFieldName = Amount ];

SqlListType and SqlListDelimiter allow to define how "List" collections are stored and viewed in SQL. Since SQL is inherently "flat," it struggles with lists. The goal of these settings is to set the storage method that matches your performance needs for "Unnesting" the data in queries. There are several possible values for the SqlListType:

SUBNODE: Stores list items in a separate global, which is more efficient for large lists (like a default for an array).

DELIMITED: Stores items as a single string with delimiters set in SqlListDelimiter 

LIST: Stored items in $List() format in memory and on disk. This is the default.

Usage:

Property Currencies As list Of %String [ SqlListDelimiter = ";", SqlListType = DELIMITED ];

There are several more settings you can configure to change how your SQL data is represented compared to the object model. Go through the documentation to uncver them all!

Discussão (0)2
Entre ou crie uma conta para continuar
Pergunta
· jan 25

I am getting ASTM messages in a single line instead of different lines like H|..../rQ|..../rL in the service. How can I resolve it?

I've modified the class file, but messages still arrive as a single line (e.g., "H|.../rQ|.../rL") instead of separate lines in the ASTM service. The <ENQ>..<EOT> header looks correct, logs show no errors, and the service receives messages fine. Is there an Ensemble 2018.1 engine setting (like line terminator handling or TCP framing) to fix the line splitting? ​

2 novos comentários
Discussão (2)2
Entre ou crie uma conta para continuar
Job
· jan 25

What Is Machine Learning? Simple Explanation for Beginners

 

Machine Learning (ML) is one of the most exciting and important technologies in today’s digital world. It is a major part of Artificial Intelligence (AI) and is used in everything from social media and online shopping to healthcare and self-driving cars. But what exactly is machine learning, and how does it work?

In this beginner-friendly guide, you’ll learn what machine learning is, how it works, its types, real-life examples, benefits, challenges, and why it matters for the future.

What Is Machine Learning?

Machine Learning is a branch of Artificial Intelligence that allows computers to learn from data and improve their performance without being explicitly programmed.

In simple words, instead of telling a computer exactly what to do, we give it data and let it learn patterns from that data.

For example:

  • Email services use machine learning to filter spam messages.
  • Netflix uses machine learning to recommend movies and shows.
  • Banks use machine learning to detect fraud.

How Does Machine Learning Work?

Machine learning works by using data, algorithms, and models.

Data Collection

First, a large amount of data is collected. This data can be text, images, numbers, or videos.

Data Preparation

The data is cleaned and organized. Errors, duplicates, and missing values are removed.

Choosing an Algorithm

An algorithm is selected based on the type of problem. Different algorithms are used for different tasks.

Training the Model

The algorithm is trained using data. During training, the model learns patterns and relationships.

Testing and Prediction

The trained model is tested with new data. If the results are accurate, it can be used to make predictions.

Types of Machine Learning

There are three main types of machine learning:

Supervised Learning

In supervised learning, the model is trained using labeled data.

Examples:

  • Email spam detection
  • Price prediction
  • Image classification

Unsupervised Learning

In unsupervised learning, the model works with unlabeled data and finds hidden patterns.

Examples:

  • Customer segmentation
  • Recommendation systems
  • Data clustering

Reinforcement Learning

In reinforcement learning, the model learns by trial and error.

Examples:

  • Game-playing AI
  • Robotics
  • Self-driving cars

Real-Life Examples of Machine Learning

Machine learning is already part of our daily lives:

  • Social Media: Shows relevant posts and ads.
  • E-commerce: Recommends products.
  • Healthcare: Helps detect diseases.
  • Finance: Identifies fraud.
  • Voice Assistants: Understand speech.

Benefits of Machine Learning

Machine learning offers many advantages:

  • Automates repetitive tasks
  • Improves accuracy
  • Handles large amounts of data
  • Makes better predictions
  • Saves time and money

Challenges and Limitations of Machine Learning

Despite its benefits, machine learning also has challenges:

  • Requires large amounts of data
  • Can be biased
  • Needs high computing power
  • Difficult to explain decisions
  • Expensive to develop

Machine Learning vs Artificial Intelligence

Many beginners confuse machine learning with artificial intelligence.

  • Artificial Intelligence is the broader concept of making machines smart.
  • Machine Learning is a subset of AI that focuses on learning from data.

The Future of Machine Learning

The future of machine learning looks very promising. It will play a major role in:

  • Healthcare
  • Education
  • Business
  • Smart cities
  • Climate research

FAQs:

What is machine learning in simple words?

Machine learning means teaching computers to learn from data and make decisions on their own.

Is machine learning the same as artificial intelligence?

No. Machine learning is a part of artificial intelligence.

Where is machine learning used?

Machine learning is used in social media, healthcare, finance, online shopping, and voice assistants.

Do I need coding to learn machine learning?

Basic programming knowledge is helpful but not always required for beginners.

Is machine learning hard to learn?

It can be challenging at first, but beginners can learn it step by step.

Conclusion:

Machine learning is a powerful technology that allows computers to learn from data and make smart decisions. It is already transforming industries such as healthcare, finance, education, and entertainment. While machine learning offers many benefits like automation and better predictions, it also comes with challenges such as data bias, high costs, and privacy concerns.

For beginners, understanding the basics of machine learning is the first step toward exploring the world of artificial intelligence. As technology continues to evolve, machine learning will become even more important in shaping the future. Learning about machine learning today can help you stay prepared for tomorrow’s opportunities.

To continue learning with simple guides, tutorials, and the latest updates on artificial intelligence and machine learning, explore more content on AI With Arzan and stay connected with a platform dedicated to beginners and tech learners.

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· jan 24 4min de leitura

通过 ODBC 将 C# 连接到 InterSystems IRIS

对于构建外部应用程序的开发人员,尤其是使用C# 等熟悉技术的开发人员来说,ODBC(开放数据库连接)是连接任何关系数据库(包括 InterSystems IRIS)的重要标准化桥梁。虽然 InterSystems 提供了自己的本地 ADO.NET 提供商,但 ODBC 驱动程序通常是与通用数据库工具和框架集成的最直接途径。

以下是使用 ODBC 驱动程序将 C# 应用程序连接到 IRIS 实例的分步指南,重点是无 DSN 连接字符串。

第 1 步:安装 InterSystems IRIS ODBC 驱动程序

在 Windows 机器上安装 InterSystems IRIS 时,默认会安装 InterSystems ODBC 驱动程序。

  • 如果 IRIS 位于同一台计算机上:驱动程序已经存在。
  • 如果 IRIS 位于远程服务器上:如果您是客户机,则必须从 WRC 网站下载并安装适用于客户机操作系统(Windows、Linux 或 macOS)和位元(32 位或 64 位)的独立 ODBC 客户机驱动程序包,或者安装客户机组件并复制 ODBC 驱动程序。

安装完成后,可在 Windows 的ODBC 数据源管理员(ODBC Data Source Administrator)工具中验证其是否存在(查找 InterSystems IRIS ODBC35 驱动程序)。

第 2 步:定义无 DSN 连接字符串

我们不在 Windows 管理员工具中创建预配置的数据源名称 (DSN),而是使用无 DSN 连接字符串。这样更便于部署,因为您的应用程序会携带所有必要的连接详细信息。

该格式指定了驱动程序名称和服务器参数:

Driver={InterSystems IRIS ODBC35};
server=127.0.0.1;
port=1972;
database=USER;
uid=_System

注意

  • 驱动程序名称InterSystems IRIS ODBC35 或有时为 InterSystems ODBC)必须与在本地 ODBC 数据源管理员中注册的名称完全一致。
  • Port 是 IRIS Superserver 端口(通常为 1972)。
  • Database 是 InterSystems IRIS 中的目标命名空间(Namespace)(如 USER 或您的自定义应用程序名称空间)。
  • 默认的 UID_System,密码是 SYS请务必在生产环境中更改这些默认值。

第 3 步:用 C# 实现连接

在 C# 项目中,您需要引用System.Data.Odbc命名空间,以使用通用 .NET ODBC 提供程序。

下面是一个最简单的 C# 示例,用于建立连接、针对默认表执行简单查询并显示结果。

using System.Data;
using System.Data.Odbc;

public class IrisOdbcExample
{
    public static void Main()
    {
        // 1. Define the DSN-less connection string
        string connectionString =
            "DRIVER={InterSystems IRIS ODBC35};" +
            "Server=127.0.0.1;Port=1972;Database=USER;" +
            "UID=_System;PWD=SYS;";

        // 2. Define the SQL Query (Example: querying the default Sample.Person table)
        string sql = "SELECT ID, Name FROM Sample.Person WHERE ID < 5";

        using (OdbcConnection connection = new OdbcConnection(connectionString))
        {
            try
            {
                connection.Open();
                Console.WriteLine("Connection successful!");

                using (OdbcCommand command = new OdbcCommand(sql, connection))
                using (OdbcDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Console.WriteLine($"ID: {reader["ID"]}, Name: {reader["Name"]}");
                    }
                }
            }
            catch (OdbcException ex)
            {
                // 3. Handle specific ODBC errors (e.g., wrong password, port blocked)
                Console.WriteLine($"ODBC Error: {ex.Message}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"General Error: {ex.Message}");
            }
            // The connection is automatically closed at
            // the end of the Using block.
        }
    }
}
 
设置 DSN

下一步

这种无 DSN 的方法提供了灵活性,并避免了客户端配置的臃肿。对于高性能的 C# 应用程序,您可以考虑使用本地InterSystems ADO.NET Provider,但对于快速集成和工具兼容性,ODBC 连接是一个可靠的选择。

❗始终记住在生产代码中使用参数化查询,以防止 SQL 注入漏洞。

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· jan 24 3min de leitura

Continuous Delivery of your InterSystems solution using GitLab - Part XIII: Optimizing build times

Welcome to the next chapter of my CI/CD series, where we discuss possible approaches toward software development with InterSystems technologies and GitLab.

Today I want to share a few approaches that will decrease your compilation time (especially if you're doing incremental/diff compilation rather than a full build).

Compiler flags and qualifiers

Code load and compilation are affected by a variety of flags and qualifiers. If you write deployment scripts for InterSystems platforms, I highly recommend reading them at least once through. While most have very specific uses, knowing what is possible can save you a lot of time one day. To list all of them, call:

Do $system.OBJ.ShowFlags()
Do $system.OBJ.ShowQualifiers()

They are also described in the docs. In any case, the most important flag here is u (update only) - if present, it skips compilation of classes that are already up-to-date. In the case where you're doing incremental compilation, having this flag saves 99% of time since only the modified code would be compiled. 
 

Load only the modified code

Recursive Import is good, but if you have a thousand classes and changed only two of them in the last commit, that's 998 classes to load for no reason at all (besides simplicity). Thankfully, git can easily answer questions, such as "what files were changed between commits abc and xyz?" Here's a sample code that accepts two git identifiers (commits, branch names, tags) and returns three lists:

  • Added files
  • Modified files
  • Deleted files

Added and modified files can be simply loaded; however, for deleted files, you'll need to write an extra handler that can determine the class name from the filename. So, in effect, you need to implement the following flow:

  1. Get the last commit hash deployed into the environment.
  2. Get the commit has to deploy.
  3. Build a diff between commits.
  4. Load and compile all added/modified classes.
  5. Delete classes based on deleted files.
  6. Store the latest commit hash (2) in IRIS.

Which is a bit more complicated to implement and maintain than just Import, but you'll considerably decrease load times.

 

Minimize passes 

Ideally you'll call Import and Compile once, each (or just import with compile flags). The worst flow (from the time perspective) is to load and compile each class one by one. While in some cases multi-stage load/compile is unavoidable, try to minimize the number of passes, especially compilation passes. 

Import method returns a local with all loaded items, so if you have several unrelated directories and you compile like this:

  • Load and compile dir A
  • Load and compile dir B
  • Load and compile dir C

You can speed things up by doing it like this instead:

  • Load dir A and get a list of loaded items
  • Load dir B and get a list of loaded items
  • Load dir C and get a list of loaded items
  • Combine lists A, B, and C
  • Compile combined list A, B, and C

Conclusion

In some cases it's possible to decrease compilation times a lot. Are there any tricks and trips you're using? Please share them in the comments. 

Discussão (0)1
Entre ou crie uma conta para continuar