Nova postagem

検索

Artigo
· Jun. 26, 2024 1min de leitura

Obtenir une liste des requêtes mises en cache et de leurs textes

Récemment, j'ai voulu obtenir une liste de toutes les requêtes mises en cache et de leurs textes. Voici comment procéder.

Créez d'abord une procédure SQL renvoyant le texte de la requête mise en cache à partir d'un nom de routine de requête mise en cache :

Class test.CQ
{

/// SELECT test.CQ_GetText()
ClassMethod GetText(routine As %String) As %String [ CodeMode = expression, SqlProc ]
{
##class(%SQLCatalog).GetCachedQueryInfo(routine)
}

}

Ensuite, vous pouvez exécuter cette requête :

SELECT Routine, test.CQ_GetText(Routine)
FROM %SQL_Manager.CachedQueryTree()

Et obtenir une liste des requêtes mises en cache :

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· Jun. 26, 2024 2min de leitura

Comment télécharger des fichiers images à partir d'un serveur FTP ?

InterSystems FAQ rubric

La procédure de téléchargement à partir d'un serveur FTP est la suivante.

1. Télécharger le fichier image sur le serveur FTP

 set tmpfile="c:\temp\test.jpg"
 set ftp=##class(%Net.FtpSession).%New() 
 // connect to FTP server
 do ftp.Connect("","<username>","<password>")
 // set transfer mode to BINARY
 do ftp.Binary()
 // Move to the directory to upload
 do ftp.SetDirectory("/temp/upload")
 // Prepare a stream of files to upload  
 set file=##class(%File).%New(tmpfile)
 do file.Open("UK\BIN\")
 // upload file
 // 1st argument: File name to create at upload destination
 // 2nd argument: File stream to upload
 do ftp.Store("test.jpg",file)
 // Logout from ftp server
 do ftp.Logout()
 // close the file
 do file.Close()
 // (Optional) Delete the uploaded file
 //do ##class(%File).Delete(tmpfile)

2. Télécharger le fichier image à partir du serveur FTP

   set ftp=##class(%Net.FtpSession).%New()     // Connect to ftp server
    do ftp.Connect("","<username>","<password>")     // Set the transfer mode to BINARY
    do ftp.Binary()     // Prepare a file stream to download and store
    set stream=##class(%FileBinaryStream).%New()
    do stream.LinkToFile("c:\temp\testdownload.jpg")
   // Go to the download directory
    do ftp.SetDirectory("/temp/download")     // Download the file and close the stream
    do ftp.Retrieve("test.jpg",stream)
    do stream.SaveStream()
    Set stream=""     // Logout from the ftp server
    do ftp.Logout()

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Jun. 25, 2024

How to send WRITE formatted output to a variable

I'm trying to keep all writes in local memory.

If you have    S %A="""HI THERE"",!,#,33.33,"" "",$ZTIMESTAMP"

and you         O 2 U 2 W @%A C 2 ZW ^SPOOL                    
^SPOOL(1,1)="HI THERE"_$c(13,10)
^SPOOL(1,2)=$c(13,12)
^SPOOL(1,3)="33.33 67016,59246.6188873"

It works just fine and the output is in the ^SPOOL global. 

However, I'm trying to avoid writing to disk.

I can't find anything besides using the SPOOL device that will allow the use of the "@" indirection.

I tried using streams but it will not allow @indirection.  Neither will set, or execute, or anything.

Is there any easy way to just set a variable to the formatted write output that the @indirection creates??

Thanks!

4 Comments
Discussão (4)2
Entre ou crie uma conta para continuar
Pergunta
· Jun. 25, 2024

SQL DatePart Not Working With ISO 8601 Formatted Date & Time

Given a properly formatted ISO 8601 date time of 2024-06-23T06:03:00Z using SQL DatePart results in an error:

  [SQLCODE: <-400>:<Fatal error occurred>]

  [%msg: <Invalid input to DATEPART() function: datepart='ss', datetime value='2024-06-23T06:03:00Z')>]

If I remove the trailing Z (for Zulu / UTC time) and leave the T, DatePart works fine.

I have also tried various ± offsets from UTC e.g. +0400 and that also results in the same SQL error

I can Trim the trailing "Z", but I would hope that DatePart would work with an acceptably formatted ISO 8601 date time string without having to go through the machinations of trimming the data.

Any help or suggestions on how to use SQL DatePart with ISO 8601 formatted Date Time strings would be appreciated.

This is the query I was experimenting with:

select 'YEAR: '||DATEPART(YEAR,'2024-06-23T06:03:00Z') 
UNION
select 'MONTH: '||DATEPART(MONTH,'2024-06-23T06:03:00Z') 
UNION
select 'DAY: '||DATEPART(DAY,'2024-06-23T06:03:00Z')
UNION
select 'HOUR: '||DATEPART(HOUR,'2024-06-23T06:03:00Z')
UNION 
select 'MINUTE: '||DATEPART(MINUTE,'2024-06-23T06:03:00Z')
UNION
select 'SECOND: '||DATEPART(SECOND,'2024-06-23T06:03:00Z')

2 Comments
Discussão (2)2
Entre ou crie uma conta para continuar
Pergunta
· Jun. 25, 2024

How can i see the request size in kilobytes/megabytes?

I need to be able to take the size of the request from a given %CSP.request

however it seems the best the docs suggest is to get the length of characters in  the request (using $order and Get, Count)...
this is not good enough for what I need to do, Any suggestions?
I scanned the docs and couldn't find anything.

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