New post

Find

Question
· 16 hr ago

Does Embedded SQL support Table Hints?

Hi everyone.

I have a function that may end up being called from a number of transformations at the same time, and within the function there's some Embedded SQL to first check if a local table has an entry, and then adds the entry if it doesn't exist.

To prevent a race condition where the function is called by two transformations and they both end up attempting to insert the same value, I'm looking to use the table hint "WITH TABLOCK" on the insert, but this seems to be failing the syntax checks within vscode.

Are table hints supported with embedded sql?

If not, is there a way to prevent the scenario from unfolding? The code I'm working with for the function is:

Class Example.Functions Extends Ens.Rule.FunctionSet
{

ClassMethod VisitIDShortener(inVisitID As %String, SourceSystem As %String) As %String
{
    //Firstly,  check to see if the table we're working with exists | This should only be an issue on first deployment to a new environment
    Set tSC = $SYSTEM.SQL.Schema.TableExists("Example.VisitIDLookup")
    If tSC'=1{
        //Buid table if it doesn't exist
        &SQL(
            CREATE TABLE Example.VisitIDLookup
            (SourceSystem varchar(10), SourceVisitID varchar(250), TargetVisitID varchar(15))
        )
    }
    //Secondly, check to see if the Global we're using for our increment exist, and create if it doesn't exist
    Set GBLCHK = $DATA(^$GLOBAL("^EMPVisitID"))
	If GBLCHK = 0{
		Set ^EMPVisitID = 0
		}

    //Check table for entry
    &SQL(
        Select TargetVisitID into :pTargetID
        FROM Example.VisitIDLookup
        Where SourceVisitID = :inVisitID And SourceSystem = :SourceSystem
    )
    //If SQLCODE is 0, we have an entry and we wnat to simply return the result
    If SQLCODE=0 {
        Set outVisitID = pTargetID
    }
    Else{
        //Increment the Global
        Do $INCREMENT(^EMPVisitID)
        
        //Use incremented value for output (with a prefix)
        Set outVisitID = "TIEGEN"_^EMPVisitID
        //Add new entry to table
        &SQL(
            Insert INTO Example.VisitIDLookup
            Set SourceSystem=:SourceSystem, SourceVisitID = :inVisitID, TargetVisitID = :outVisitID
        )
    }

    Quit outVisitID
}

}
4 new Comments
Discussion (4)2
Log in or sign up to continue
Announcement
· 16 hr ago

[Video] Compreendendo a Estrutura dos Recursos HL7 FHIR

Olá Comunidade,

Assista ao mais recente vídeo no canal InterSystems Developers YouTube:

⏯ Understanding the Structure of HL7 FHIR Resources

Obtenha uma introdução à estrutura dos recursos HL7 FHIR. Veja como visualizar e ler a representação em árvore de um recurso no site HL7 FHIR, que permite compreender os diferentes elementos de dados incluídos em um recurso. Além disso, aprenda como ver um recurso em XML, JSON ou Turtle e onde encontrar o diagrama UML (Universal Modeling Language) para um recurso FHIR.

Assista aos novos vídeos! 👍

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

Direct access to a global without SQL

Hi everyone,
I have this global with 2 informations in it: Reference (ex: 1329) and Code (ex: JMMK-G1D6).

^DataTest    =     3
^DataTest(1)    =     $lb("","1329","JMMK-G1D6")
^DataTest(2)    =     $lb("","1516","AMEV-GVPF")
^DataTest(3)    =     $lb("","2333","4QC6-4HW3")

With ObjectScript, i want to test if Reference 1516 exists in the global. 
In the InterSystems portal, i can do it with SQL (SELECT count(*) FROM DataTest where Reference = '1516'), but can we do the same in ObjectScript without SQL and manipulating the global directly ?

Thanks for help.

4 new Comments
Discussion (4)4
Log in or sign up to continue
Article
· 19 hr ago 13m read

レシピデータセットを外部テーブルで読み込み、組み込みPythonでLLMを使って分析する (Langchain + OpenAI)

我々には、Redditユーザーが書いた、おいしいレシピデータセット がありますが, 情報のほとんどは投稿されたタイトルや説明といったフリーテキストです。埋め込みPythonLangchainフレームワークにあるOpenAIの大規模言語モデルの機能を使い、このデータセットを簡単にロードし、特徴を抽出、分析する方法を紹介しましょう。

データセットのロード

まず最初に、データセットをロードするかデータセットに接続する必要があります。

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