查找

Résumé
· Août 25

Publicações Desenvolvedores InterSystems, Agosto 18 - 24, 2025, Resumo

Agosto 18 - 24, 2025Week at a GlanceInterSystems Developer Community
Annonce
· Août 25

Developing with InterSystems Objects and SQL – In Person September 15-19, 2025 / Registration space available

Developing with InterSystems Objects and SQL – In Person September 15-19, 2025

  • This 5-day course teaches programmers how to use the tools and techniques within the InterSystems® development environment.
  • Students develop a database application using object-oriented design, building different types of IRIS classes.
    • They learn how to store and retrieve data using Objects or SQL, and decide which approach is best for different use cases.
    • They write code using ObjectScript, Python, and SQL, with most exercises offering the choice between ObjectScript and Python, and some exercises requiring a specific language.
  • This course is applicable for users of InterSystems IRIS® data platform and InterSystems Caché®
  • Self-Register Here
Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Question
· Août 25

Catching WorkQueue Errors

I'm trying to catch some WorkQueue errors that are happening on 2019 but not on more recent versions.

I'm getting an error when trying to call a class method via a workQueue. It functions properly in 2024.1. When calling the method, it immediately errors. I have logging at the top of the method that never gets set. 

The error being returned by Iris is simply an "ERROR #5039: An error occurred while calling function  s %sc=##class(|"NS"|Path.To.Class).ClassMethod(.%p1,.%p2)"

The parameter counts match and are appropriate for the method.

When I catch the full stack, it's erroring on the WorkQueue compiled routine, somewhere around startWork+233^%WorkQueueMgr. The error stack mentions a few lines, all in startWork. Looking at what, I think is, the associated inc file (occWorkQueue.inc), there's some mention of turning on logging by setting ^%SYS("WQM","EnableWorkLogging"). If that's true, it will set the error being passed in into the ^%ISCLOG global. However, even when I do set ^%SYS("WQM","EnableWorkLogging") to 1, and ^ISCLOG to 4 (or higher), I never see the logs I'd expect to. I know there are logs within the routine that set values and errors to $$$WorkSysLog at levels 2 and 3, so setting ^ISCLOG to 4 should catch those errors. 

How can I view the errors being thrown by the compiled routine? Does the value of "EnableWorkLogging" only matter at some stage I can't set? 

7 Comments
Discussion (7)3
Connectez-vous ou inscrivez-vous pour continuer
Article
· Août 25 3m de lecture

Programação Prática em ObjectScript: De JSON a Globals e a SQL

Ao começar a usar o InterSystems IRIS ou Cache, os desenvolvedores frequentemente se deparam com três conceitos principais: Objetos Dinâmicos, Globals e Tabela Relacional. Cada um tem seu papel na construção de soluções escaláveis e fáceis de manter. Neste artigo, vamos percorrer exemplos de código práticos, destacar as melhores práticas e mostrar como esses conceitos se conectam.

1. Trabalhando com Objetos Dinâmicos

Objetos dinâmicos (%DynamicObject e %DynamicArray) permitem que os desenvolvedores manipulem estruturas semelhantes a JSON diretamente no ObjectScript. Eles são especialmente úteis para aplicações modernas que precisam analisar, transformar ou gerar JSON.

Exemplo: Criando e Manipulando Objetos Dinâmicos

    // Create a Dynamic object
    Set obj - {}

    // Add properties
    Set obj.name = "Vachan"
    Set obj.age = 25
    // Nested objects
    Set obj.address = {"city":"Bengaluru", "zip":"560000"}
    
    // Add an Array
    Set obj.skills = ["Objectscript", "SQL"]
    
    // Convert to JSON string
    Set json = obj.%ToJSON()
    Write json,!
    
    // Parse JSON string back to an object
    Set parser = {}.%FromJSON(json)
    Write parser.name

Melhores Práticas

  • Sempre valide a entrada JSON com %FromJSON() para capturar erros.
  • Use obj.%Get("property") quando não tiver certeza se uma propriedade existe.
  • Prefira %DynamicArray para estruturas do tipo lista..

2. Usando Globals de forma Eficaz

Globals são arrays esparsos hierárquicos armazenados diretamente no motor de banco de dados do IRIS. Eles são extremamente rápidos e podem armazenar praticamente qualquer estrutura.

Exemplo: Armazenando Dados em Globals

// Store student data in a global
SET ^Student(1,"Name") = "Alice"
SET ^Student(1,"Age") = 29
SET ^Student(2,"Name") = "Bob"
SET ^Student(2,"Age") = 34
// Retrieve data
WRITE ^Student(1,"Name")  // outputs: Alice
// Iterate over all students
SET id=""
FOR  SET id=$ORDER(^Student(id)) QUIT:id=""  {
    WRITE "Student ",id,": ",^Student(id,"Name")," (Age ",^Student(id,"Age"),")",!
}

Melhores Práticas:

  • Defina uma estrutura global clara antes de codificar (evite chaves ad hoc).
  • Use globals para armazenamento de alto desempenho quando o overhead do SQL não for necessário.
  • Para dados de aplicação, prefira classes persistentes com globals gerenciados internamente

3. Criando Tabelas SQL Relacionais

No IRIS, tabelas relacionais podem ser criadas usando DDL SQL e classes persistentes.

Exemplo: Criando uma Tabela SQL via DDL

CREATE TABLE Employee (
    ID SERIAL PRIMARY KEY,
    Name VARCHAR(50),
    Age INT,
    Department VARCHAR(50)
);

Exemplo: Criando a mesma tabela como uma Classe Persistente

Class Company.Employee Extends (%Persistent) {
    Property Name As %String(MAXLEN=50);
    Property Age As %Integer;
    Property Department As %String(MAXLEN=50);
}

Uma vez compilada, esta classe cria automaticamente um global subjacente e uma tabela SQL. Agora você pode usar tanto o ObjectScript quanto o SQL:

// Create and save an employee
SET emp = ##class(Company.Employee).%New()
SET emp.Name = "Charlie"
SET emp.Age = 40
SET emp.Department = "IT"
DO emp.%Save()

// Query employees with SQL
&sql(SELECT Name, Age FROM Company.Employee)
WHILE (SQLCODE=0) {
    WRITE "Employee: ",Name,", Age: ",Age,!
    FETCH NEXT
}

Melhores Práticas:

  • Prefira classes persistentes para aplicações fáceis de manter.
  • Use DDL SQL para definições rápidas de tabelas ou integração com sistemas externos.
  • Sempre defina índices para propriedades frequentemente consultadas.

 

RESUMO:

Seja para analisar payloads JSON, gerenciar dados de consulta de alta velocidade ou projetar tabelas relacionais, entender quando usar objetos dinâmicos, globals ou classes persistentes é fundamental para se tornar um desenvolvedor ObjectScript eficaz.

Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Résumé
· Août 25

InterSystems Developers Publications, Week August 18 - 24, 2025, Digest

Articles
Announcements
Questions
#InterSystems IRIS
Is there a way to drop/remove an inherited setting (from the SETTINGS class parameter) in an interoperability business host?
By Timothy Leavitt
Do I need a separate python iris connection for each Namespace?
By Ronaldo Nascimento
How much length of data stored in Binary Resource? the Data is base64bineary it support the large data like 50 lac characters length on base64 data(35mb) pdf data stored in IRIS Binary Resource?
By Rutvik ISM
About the deprecated libraries, is there an expiration time in the code?
By André Dienes Friedrich
How to change the IRIS user when starting a terminal session in an IRIS container?
By Ali Nasser
How to Handel large data like 50 lac characters support in Base64 binary in Binary FHIR Resource ? i
By Rutvik ISM
VS code not importing CSP files
By Peter Smit
Router does not work with number parameter in %CSP.REST
By Sébastien Demoustiez
How to integrate Google Cloud Pub/Sub with InterSystems IRIS?
By Rama Krishna Kummari
#Caché
#HealthShare
#InterSystems IRIS for Health
#Open Exchange
#InterSystems IRIS BI (DeepSee)
BI Architect expressions
By Dmitrij Vladimirov
August 18 - 24, 2025Week at a GlanceInterSystems Developer Community