I want to Fetch columnType for sql query
Hii all,
I'm trying to fetch columnType from resultSet of type %Library.ProcedureContext.
Executed the class query by %Execute after %PrepareClassQuery.
Product version: IRIS 2023.1
Discussion (4)2
Comments
1. Get the NextResult() resultset
2. Get the Metadata from the resultset
How to get the column type from Metadata ?
Hi @Prashant Singhal ! Please, read this interesting article to get the data type from a query:
https://community.intersystems.com/post/sql-statement-metadata
Hi Prashant,
You can get the values from
ClassMethod GetColumnType() As %String
{
set statement = ##class(%SQL.Statement).%New()
set tSC = statement.%PrepareClassQuery("Sample.Person","TestQuery")
set result = statement.%Execute()
#dim meta As %SQL.StatementMetadata
set meta = result.%GetMetadata()
write meta.columns.GetAt(1).ODBCType ;fetch first field
}