Rechercher

Article
· 8 hr ago 2m read

Archivos temporales y Singletons: limpiad lo que generéis.

Hay un patrón con el que me he encontrado varias veces en el que necesito usar un archivo o carpeta temporal y que se limpie en algún momento más adelante.

Lo natural aquí es seguir los patrones de "Robust Error Handling and Cleanup in ObjectScript" usando un try/catch/pseudo-finally o un objeto registrado para gestionar la limpieza en el destructor. %Stream.File* también tiene una propiedad “RemoveOnClose” que podéis activar… pero usadla con cuidado, porque podríais eliminar accidentalmente un archivo importante, y este indicador se reinicia al llamar a %Save(), así que tendréis que volver a ponerlo a 1 después de hacerlo.

Pero hay un caso complicado: imaginad que necesitáis que el archivo temporal sobreviva en un nivel de pila superior. Por ejemplo:

ClassMethod MethodA()
{
    Do ..MethodB(.filename)
    // Do something else with the filename
}

ClassMethod MethodB(Output filename)
{
    // Create a temp file and set filename to the file's name
    Set filename = ##class(%Library.File).TempFilename()
    
    //... and probably do some other stuff
}

Siempre podríais pasar objetos %Stream.File* con RemoveOnClose puesto a 1, pero aquí realmente estamos hablando solo de archivos temporales.

Aquí es donde entra el concepto de “Singleton”. En IPM tenemos una implementación base en %IPM.General.Singleton que podéis extender para cubrir distintos casos de uso. El comportamiento general y el patrón de uso son:

  • En un nivel de pila superior, llamáis a %Get() en esa clase y obtenéis la única instancia, que también será accesible mediante llamadas a %Get() en niveles inferiores.
  • Cuando el objeto sale de ámbito en el nivel de pila más alto que lo usa, se ejecuta el código de limpieza.

Esto es un poco mejor que usar una variable %, porque no necesitáis comprobar si está definida, y además sobrevive a los NEW sin argumentos en los niveles de pila inferiores gracias a cierta magia profunda de objetos.

Pasando a los archivos temporales, IPM también tiene un singleton gestor de archivos temporales. Aplicándolo a este problema, la solución es:

ClassMethod MethodA()
{
    Set tempFileManager = ##class(%IPM.Utils.TempFileManager).%Get()
    Do ..MethodB(.filename)
    // Do something else with the filename
    // The temp file is cleaned up automatically when tempFileManager goes out of scope
}

ClassMethod MethodB(Output filename)
{
    Set tempFileManager = ##class(%IPM.Utils.TempFileManager).%Get()
    // Create a temp file and set filename to the file's name
    Set filename = tempFileManager.GetTempFileName(".md")
    
    //... and probably do some other stuff
}
Discussion (0)1
Log in or sign up to continue
Announcement
· 9 hr ago

[Video] SQL Tricks and Tips

Hey Community!

We're happy to share a new video from our InterSystems Developers YouTube:

⏯  SQL Tricks and Tips @ Ready 2025

This presentation introduces two helpful SQL features in InterSystems IRIS: Common Table Expressions (CTEs) and Limit/Offset. CTEs, available since version 24.1, let users simplify complex queries by breaking them into reusable, readable blocks that can be used with SELECT, INSERT, UPDATE, and DELETE statements.
The Limit/Offset feature, added in version 25.1, provides a flexible alternative to the TOP clause, allowing users to limit returned rows and skip specific records, ideal for pagination. Together, these features make queries easier to write, read, and optimize, while the SQL engine automatically handles efficient execution and plan optimization.

Presenters:
🗣 Ismail Ben Atitallah, Principal Systems Developer, InterSystems
🗣 Yiwen Huang, Systems Developer, InterSystems

Enjoy watching, and subscribe for more videos! 👍

Discussion (0)1
Log in or sign up to continue
Announcement
· 10 hr ago

[Video] Enhancing Customer Engagement with Vector Search - Building a Customer Facing Chatbot

Hey Developers,

Enjoy the new video on InterSystems Developers YouTube

⏯ Enhancing Customer Engagement with Vector Search - Building a Customer Facing Chatbot @ READY 2025

Explore how InterSystems IRIS vector search anchors chatbot capabilities by delivering fast, relevant, and context-aware responses. In this session, we’ll walk through the key benefits and best practices for using vector search in conjunction with your LLM to power your chatbots. You’ll also meet our new chatbot AskMe, available on our documentation and learning sites; it’s designed to help you find answers quickly and navigate content with ease. Whether you’re building AI-driven support or optimizing existing solutions, you’ll leave with actionable insights to improve and enhance self-service experiences.

Presenters:
🗣 @Brenna Quirk, Sr. Technical Online Course Developer at InterSystems
🗣 @Jim Breen, Director of Global Learning at InterSystems
🗣 @Kim Koehler, Manager, Learning Technology at InterSystems 

Enjoy watching, and look forward to more videos!👍

Discussion (0)1
Log in or sign up to continue
Question
· 10 hr ago

Classic Essentials Hoodie for Men and Women – A Casual Must-Have

In the world of fashion, few items have achieved the timeless appeal of the hoodie. Among the most versatile and comfortable pieces in any wardrobe, the Classic Essentials Hoodie for men and women has become a staple that blends style, comfort, and practicality seamlessly. Whether you are lounging at home, heading out for a casual day in the city,        Essentials hoodie  
   or layering for outdoor adventures, this hoodie proves to be an indispensable part of modern fashion.

Timeless Design Meets Everyday Comfort

The Classic Essentials Hoodie is designed with simplicity and functionality in mind. Its clean lines and minimalistic style make it a perfect match for almost any outfit. Unlike hoodies with excessive branding or complicated designs, the classic hoodie embraces a more understated aesthetic that appeals to people of all ages and tastes. The soft fabric, usually a blend of cotton and polyester, provides a cozy feel while ensuring durability. This combination allows the hoodie to maintain its shape and softness even after multiple washes, making it a reliable choice for everyday wear.

One of the most appealing aspects of this hoodie is its universal fit. Designed to suit both men and women, it offers a flattering silhouette that doesn’t compromise comfort. The adjustable hood and ribbed cuffs add to its practical design, allowing wearers to stay warm and snug during cooler weather. Whether paired with jeans, joggers, or even shorts, the hoodie adapts effortlessly to different looks, making it an essential piece for any casual wardrobe.

Versatility That Fits Any Lifestyle

The Classic Essentials Hoodie isn’t just about comfort; it’s about versatility. Its neutral tones and simple design make it suitable for a variety of occasions. For students and young professionals, it offers a relaxed yet polished look that can be worn to class, casual office settings, or weekend meetups. For athletes or fitness enthusiasts, it serves as a comfortable layer for warm-ups, cool-downs, or outdoor exercises. Its lightweight nature ensures ease of movement, while the hood provides additional protection from wind and light rain.

Moreover, this hoodie is perfect for layering. It can be worn over t-shirts, long sleeves, or even under jackets, providing both style and warmth. This adaptability makes it an ideal choice for transitional seasons like spring and fall, when the weather can be unpredictable. Unlike other seasonal apparel that becomes obsolete after a few months, the Classic Essentials Hoodie remains relevant year after year, cementing its status as a wardrobe essential.

A Wardrobe Staple for Everyone

One of the reasons the Classic Essentials Hoodie has become so popular is its universal appeal. It transcends gender, age, and fashion trends, making it a reliable option for everyone. The hoodie’s simplicity allows wearers to personalize their style effortlessly. Some may prefer a monochromatic look, pairing it with matching pants or sneakers, while others might layer it with patterned or textured clothing to create a more dynamic outfit. Regardless of personal style, the hoodie serves as a comfortable canvas for self-expression.

In addition to style, the hoodie offers practical benefits that enhance everyday life. The front pocket provides convenient storage for small essentials like phones, keys, or wallets,      Essentials T-Shirt 
   while the soft inner lining adds warmth and coziness during cooler days. Its breathable fabric prevents overheating, ensuring comfort during extended wear. This balance between style and functionality is what makes the Classic Essentials Hoodie a must-have item for anyone seeking both fashion and practicality.

Investing in Timeless Comfort

Purchasing a Classic Essentials Hoodie is more than just buying a piece of clothing; it’s an investment in timeless comfort and style. Unlike trendy items that quickly go out of fashion, this hoodie maintains its appeal across seasons and years. Its durable construction ensures long-lasting use, while its versatile design makes it easy to pair with other wardrobe staples. Whether you’re dressing for a casual outing, relaxing at home, or layering for outdoor adventures, the hoodie delivers consistent comfort and style.

In conclusion, the Classic Essentials Hoodie for men and women is not just another casual clothing item—it is a lifestyle choice. Its timeless design, unmatched comfort, and incredible versatility make it a wardrobe essential for people of all ages. By investing in this hoodie, you are choosing a piece that adapts to your lifestyle, enhances your daily comfort, and allows you to express your style effortlessly. If there is one item that deserves a place in every closet, the Classic Essentials Hoodie undoubtedly earns that spot.

Discussion (0)1
Log in or sign up to continue
Article
· 18 hr ago 3m read

Create Foreign Tables Using SQL via JDBC

Hi everyone. Long time no see. Again, I would like to share what I am studying recently Create Foreign Tables Using SQL via JDBC.

Since I am learning about the IRIS BI at the same time, so I started with this Sample-BI docker environment

https://github.com/intersystems/Samples-BI

 

After starting the environment, login to the management portal http://localhost:52773/csp/sys/UtilHome.csp  with the user Superuser.

Switch the namespace to IRISAPP.

 

😀 We will find out that all the sample data are stored in this namespace IRISAPP. Let's find a simple table for testing the Foreign Table feature 🤣

System Explorer > SQL

 

Let's try the table HoleFoods.Outlet by Executing the following SQL query in the Execute Query tab

SELECT
ID, City, Country, Latitude, Longitude, Population, Type
FROM HoleFoods.Outlet

 

Great!!😉 there are 35 entries in this table. Let's use it.

 


Step1  -  Setup the JDBC connection

By studying the document below, InterSystems IRIS db can be connected by JDBC by the following way

Using the SQL Gateway as a JDBC Data Source

So, let's using the Namespace IRISAPP as the JDBC source database for testing, and set up a connection for it.

Add a new connection by System  > Configuration  > SQL Gateway Connections 

 

Input the following

Connection name  testjdbc
User superuser
Password {you own password}
Driver name com.intersystems.jdbc.IRISDriver
URL  jdbc:IRIS://127.0.0.1:1972/IRISAPP

Leave Class path blank in this case, because is connecting to InterSystems IRIS DB. If connecting to the 3rd party DB, remember to download the JDBC driver file (.jar) and specific the path of the drive in the Class path filed.

 

Save and Test the Connection. Connection successful should be expected. 😁

Yeah!!! we finished the 1st step.

 


Step 2 - Create Foreign Table

Now switch to another Namespace USER, which do no contain the table HoleFoods.Outlet. 😉

Here we would like to query this external table HoleFoods.Outlet by making use the feature of Foreign Table. (In InterSystems IRIS, different Namespace, can be config to point to different DB. In this example, Namespace IRISAPP and Namespace USER are pointing to different DB. As a result, we cannot query the table Namespace IRISAPP from Namespace USER directly. )

 

By studying the document below, we can directly create foreign table by SQL.😁👍

Foreign Tables

So let's go to the SQL execution page again. System Explorer > SQL

 

1. Define a Foreign Server

Now we are going to define a Foreign Server Sample.testDB by the following SQL. testjdbc is the name that we defined in the SQL Gateway JDBC connection in the pervious step.

CREATE FOREIGN SERVER Sample.testDB FOREIGN DATA WRAPPER JDBC CONNECTION 'testjdbc'

 

 

2. Define a Foreign Table

Now we are going to define a Foreign Table demo.outlet, which is pointing to the table HoleFoods.Outlet through the JDBC gateway

 

CREATE FOREIGN TABLE demo.outlet SERVER Sample.testDB TABLE 'HoleFoods.Outlet'

Let's check the result from the table list

Yeah!!!!  A Foreign Table demo.outlet is created. Oooo the schema is read and created automatically btw😂Happy happy.

 


Finally, test the Foreign Table by running the following SQL

SELECT * FROM demo.outlet

 

 

35 Outlets are returned!!! Yeah!! We made it.🤣

 


Only for your reference

Dropping the Foreign Table demo.outlet 

DROP FOREIGN TABLE demo.outlet

 

 

Dropping the  Foreign Server Sample.testDB 

DROP FOREIGN SERVER Sample.testDB CASCADE

 

That's all I want to share!!! Thanks for reading😘

Discussion (0)1
Log in or sign up to continue