New post

Find

Question
· Jan 2

Nested queries

Hi Guys,

This Nested query is not working for some reason, but they work fine when executing  separately ?  

select id from FDRD_Com.List where vehicle in (select Car from FDRD_Com.Prod where ProductLineName='Toyota' and Car is not null)

 

Thanks

3 Comments
Discussion (3)2
Log in or sign up to continue
Announcement
· Jan 2

Resumen del mes de diciembre, 2024

¿No habéis podido entrar en la Comunidad todo lo que os gustaría? ¡No os preocupéis! Os traemos un resumen de todo lo que hemos publicado en el mes de diciembre. Seguid leyendo y no os lo perdáis ⬇️⬇️
Estadísticas generales
✓ publicaciones nuevas:
 18 artículos
 6 anuncios
 7 nuevas preguntas
Top 10 publicaciones
Top 5 Autores
Todos los artículos
#InterSystems IRIS
Actualización de Auditoría en 2024.3 - Eventos de Sentencias SQL Más Detallados
Por Alberto Fuentes
HL7 -> SDA -> FHIR -> Crecimiento Personal
Por Andre Ribera
Construyendo una imagen de IRIS con CPF Merge
Por Luis Angel Pérez Ramos
EduVerse: Asistente de Aprendizaje Accesible
Por Rolano Rebelo
QuinielaML - Predicción de la 27ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
¿Cómo generar un error personalizado?
Por Ricardo Paiva
QuinielaML - Predicción de la 29ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Usando IRIS y Presto para consultas SQL de alto rendimiento y escalabilidad
Por Yuri Marx
Mejoras en la interoperabilidad de InterSystems con IRIS Whiz
Por Rob Ellis
Editad vuestros Globals con VSCode y YAML
Por Yuri Marx
QuinielaML - Predicción de la 31ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Cómo Monitorear el crecimiento del tamaño de la base de datos y emitir alertas
Por Ricardo Paiva
Análisis más rápido de mensajes con IRIS Whiz
Por Rob Ellis
 
#Comunidad de Desarrolladores Oficial
 
#Portal de ideas de InterSystems
 
#Global Masters
 
#Portal de Formación
 
Todos los anuncios
Todas las preguntas
diciembre, 2024Month at a GlanceInterSystems Developer Community
Discussion (0)1
Log in or sign up to continue
Digest
· Jan 2

Resumen de la Comunidad de Desarrolladores, diciembre 2024

Hola y bienvenidos al boletín de la comunidad de desarrolladores diciembre 2024.
Estadísticas generales
✓ publicaciones nuevas:
 18 artículos
 6 anuncios
 7 nuevas preguntas
10 nuevos miembros se unieron en diciembre
1,958 contenidos publicados de forma constante
721 miembros se unieron de forma constante
Publicaciones populares
Autores populares
Artículos
#InterSystems IRIS
Actualización de Auditoría en 2024.3 - Eventos de Sentencias SQL Más Detallados
Por Alberto Fuentes
HL7 -> SDA -> FHIR -> Crecimiento Personal
Por Andre Ribera
Construyendo una imagen de IRIS con CPF Merge
Por Luis Angel Pérez Ramos
EduVerse: Asistente de Aprendizaje Accesible
Por Rolano Rebelo
QuinielaML - Predicción de la 27ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
¿Cómo generar un error personalizado?
Por Ricardo Paiva
QuinielaML - Predicción de la 29ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Usando IRIS y Presto para consultas SQL de alto rendimiento y escalabilidad
Por Yuri Marx
Mejoras en la interoperabilidad de InterSystems con IRIS Whiz
Por Rob Ellis
Editad vuestros Globals con VSCode y YAML
Por Yuri Marx
QuinielaML - Predicción de la 31ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Cómo Monitorear el crecimiento del tamaño de la base de datos y emitir alertas
Por Ricardo Paiva
Análisis más rápido de mensajes con IRIS Whiz
Por Rob Ellis
#Comunidad de Desarrolladores Oficial
#Portal de ideas de InterSystems
#Global Masters
#Portal de Formación
Anuncios
Preguntas
diciembre, 2024Month at a GlanceInterSystems Developer Community
Article
· Jan 2 5m read

Creating a REST client to get Tracks from Spotify REST API - Part5 creating my own REST service

Last Chapter: Creating a REST client to get Tracks from Spotify REST API - Part4 Save the Search Result

Git link: https://github.com/ecelg/InterSystems-IRIS-as-a-Spotify-REST-client

 

OK.... based on what I have done.... I am able to 

1. Query Track information by making use of the Spotify API

2. Store the necessary data into my own album, artists, and track table

 

so.... what next?🤔 How about I set up my own REST API service on my IRIS for the other people to query my table?🤔🤨

 

ok... 1st... start from document Introduction to Creating REST Services

so we have 2 ways to implement a REST service on IRIS

Way 1. Using the OpenAPI 2.0 specification 

Way 2. Creating a REST Service Manually

mummmm...both are ok for me.... how about trying the way 2?

 

OK Let's start with a simple HelloWorld!!!


1.  Create a business service class rest.bs.RestService.cls extend the class  %CSP.REST   

Create a folder bs under the folder rest

Create a class RestService.cls under the folder bs

replace the code by the following

Class rest.bs.RestService Extends %CSP.REST
{

Parameter CONTENTTYPE = "application/json";
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
		<Route Url="/hello" Method="GET" Call="HelloWorld" />
	</Routes>
}

ClassMethod HelloWorld() As %Status
{
	//define a DynamicObject
	#dim tJSON As %DynamicObject={}
	
	//set the keys and values
	set tJSON."test_message"="Hello World!!"
	// write to response
	do ##class(%JSON.Formatter).%New().Format(tJSON)
	
	return $$$OK
}

}

Save it

 


2. Create a Web Application for this REST service

Open the management portal

Go to the page Web Applications

Name : /csp/myapi

Namespace : demo

Dispatch Class: rest.bs.RestService

Save

Assign %All in the application roles

 


3. Test the api

GET localhost/csp/myapi/hello

localhost can be replace as the url of your server, /csp/myapi is the path that I defined in the web application, /hello
is the path of the class method I would like to call, which is defined in the class rest.bs.RestService

Yeah!!! My REST API is working!!!😆😆

 


Now... let's try to let our API users search our tracks by the id of the track table

and write it to JSON as response to our API users

 

4. add the routing path to the class rest.bs.RestService.cls

We add the /:id as the arguments(in this case, it will pass into the 1st argument) for query, this argument will pass into the class method Track(will be implement in the next session) for process

<Route Url="/spotify/track/:id" Method="GET" Call="Track" />

 

 


5. Add the Class Method Track

This method will look up the related data based on the argument /:id  and return as JSON response

Add the following class method in to the class rest.bs.RestService.cls

ClassMethod Track(pId As %Integer) As %Status
{
	kill a
	//open an object with id
	set a=##class(rest.spotify.track).%OpenId(pId)
	
	//convert to JSON String
	set b=""
	do a.%JSONExportToString(.b)
	kill a
	
	// write to response
	w b
	return $$$OK
}

save the class

 


6. Test it!!!!

GET localhost/csp/myapi/track/5

localhost can be replace as the url of your server, /csp/myapi is the path that I defined in the web application, /track
is the path of the class method I would like to call, which is defined in the class rest.bs.RestService/5 is the argument for looking up the track by id

Yeah!!!  working!!!!😀

 


Ok seems working well!!!😁 My final question is... how to let our user search for a track???

mummmm... at least.. we can search by name of the track, market, or maybe by artist

OK... let's add another route and class method to handle it!!

 

7. add the routing path to the class rest.bs.RestService.cls

<Route Url="/spotify/searchtrack" Method="GET" Call="SearchTrack" />

 



8. Add the Class Method SearchTrack

This method will look up the related data based on the parameters name, market, artist  and return as JSON response

 

to get the parameters, you may use the code  $GET(%request.Data({paramete_key},1),""), for example to get the parameter name  $GET(%request.Data("name",1),"")

Add the following class method in to the class rest.bs.RestService.cls
 

ClassMethod SearchTrack() As %Status
{
	// get the parameter "name"
	#dim tname As %String=$GET(%request.Data("name",1),"")
	// get the parameter "name"
	#dim tmarket As %String=$GET(%request.Data("market",1),"")
	// get the parameter "name"
	#dim tartists As %String=$GET(%request.Data("artists",1),"")
	
	set sname="%"_tname_"%"
	set trowid=0
	&sql(SELECT top 1 ID into :trowid FROM rest_spotify.track where name like :sname order by popularity desc)
	set tarowid=""
	if (tartists'="")
	{
		set sartists=tartists
		&sql(SELECT top 1 ID into :trowid FROM rest_spotify.track where name like :sname  and album->artists->name like :sartists order by popularity )
	}
	if tarowid'="" set trowid=tarowid
	/*//debug
	//define a DynamicObject
	#dim tJSON As %DynamicObject={}
	//set the keys and values
	set tJSON."debug_message_name"=$replace(tname," ","%20")
	set tJSON."debug_message_market"=tmarket
	set tJSON."debug_message_rowid"=trowid
	// write to response
	do ##class(%JSON.Formatter).%New().Format(tJSON)
	*/
	if (trowid="")
	{
		/*//debug
		//define a DynamicObject
		#dim tJSON As %DynamicObject={}
		//set the keys and values
		set tJSON."debug_message_rowid"="not found"
		// write to response
		do ##class(%JSON.Formatter).%New().Format(tJSON)
		*/
		set tquery="offset=5&limit=10&query="_tname_"&type=track&market="_tmarket
		set str=##class(rest.utli.requestUtli).getdata("Spotify","/search",tquery)
		set std=##class(rest.utli.spotifyUtli).getSearchResult(str)
		&sql(SELECT top 1 ID into :trowid FROM rest_spotify.track where name like :sname order by popularity desc)
	}
	if (trowid>0)
	{
		//open an object with id
		set a=##class(rest.spotify.track).%OpenId(trowid)
		
		//convert to JSON String
		set b=""
		do a.%JSONExportToString(.b)
	
		// write to response
		w b
		return $$$OK
	}
	
	return $$$OK
}

save the class

 


9. Test it again!!!

 

GET localhost/csp/myapi/searchtrack?name=APT&market=SG&artists=

localhost can be replace as the url of your server, /csp/myapi is the path that I defined in the web application, /track
is the path of the class method I would like to call, which is defined in the class rest.bs.RestServicename, market, artist are the parameter input for searching

Yeah!! working!!!😁

Let's try one more

GET localhost/csp/myapi/searchtrack?name=call me maybe&market=SG&artists=Carly Rae Jepsen

Discussion (0)1
Log in or sign up to continue
Article
· Jan 1 2m read

第六十二章 假脱机设备 - 查看 ^SPOOL 全局

第六十二章 假脱机设备 - 查看 ^SPOOL 全局

查看 ^SPOOL 全局

与任何下标的全局变量一样,您可以通过发出 WRITE 命令来显示 spool 文件中的行,如下所示:

   WRITE "1st spool file node: ",^SPOOL(1,1),!

但是,要查看和编辑假脱机文件本身,请转到管理门户并选择 System ExplorerGlobals。选择您当前的命名空间,找到 SPOOL 全局变量,然后单击 data。这将显示类似于以下示例的假脱机文件数据。

在下面的假脱机文件中,() 终止字符结束假脱机文件中的每个节点行。这些终止字符是假脱机文件的一部分,作为 $CHAR(13,10) 连接到文本字符串(ReturnLine Feed)。

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