User bio
404 bio not found
Malaga, Spain
Member since Feb 21, 2018
Pinned posts:
Replies:

Hi community:

  • My name is Francisco López, AKA Kurro López
  • I'm from Spain, born and living in Málaga (Andalusia) in southern Spain, close to Mediterranean Sea.
  • Working as project manager in Salutic Soluciones, SL. This company is dedicated to creating software for medical management and services for health insurance companies.
  • I have extensive programming experience in several languages, from Clipper 87 to C#, including Python, PowerBuilder, Visual Basic, and, of course, ObjectScript. I've spent a long career dedicated to programming and the technical and functional analysis of new processes. I love programming in IRIS because it gives me a lot of freedom when generating complex workflows that would be much slower to complete with other languages.
  • My main hobby is the mountains. I love long walks, hiking, and discovering new places. I used to do mountain running, but my knees aren't what they used to be.
  • LinkedIn: https://www.linkedin.com/in/franciscolopezdelasheras/
  • I won't be attending READY 2025 this year, but I have attended in previous years and it's a great experience that everyone should go to at least once.

Also... you can create a ClassMethod to pass the fields to retrieve

ClassMethod DynamicQuery(columns As %String) As %Status
{
    // columns: comma-separated string, e.g. "Book,Author"
    
    // Basic validation
    If columns = "" {
        Write "No columns specified.", !
        Quit $$$ERROR
    }
    
    // Build the SQL query
    Set sql = "SELECT " _ columns _ " FROM myTables.Books"
    
    Try {
        Set stmt = ##class(%SQL.Statement).%New()
        Set sc = stmt.%Prepare(sql)
        If $$$ISERR(sc) {
            Write "Error preparing the query.", !
            Quit sc
        }
        
        Set rset = stmt.%Execute()
        
        While rset.%Next() {
            For i = 1:1:rset.%ColumnCount {
                Write rset.%GetColumnName(i), ": ", rset.%Get(i), " | "
            }
            Write !
        }
    } Catch ex {
        Write "Error executing the query: ", ex.DisplayString(), !
        Quit ex.AsStatus()
    }

    Quit $$$OK
}

Then, call it using this command:

Do ##class(MyApp.Utils).DynamicQuery("Book,Author")

Hi @Touggourt 

If you want to retrieve the values, prepare the query by concatenating the values ​​you want to retrieve

set var1 = "Book"
set var2 = "Author"
set query = "SELECT "_var1_","_var2_" FROM myTables.Books"
set statement = ##class(%SQL.Statement).%New()

set status = statement.%Prepare(query)
set rset = statement.%Execute()
do rset.%Display()

Have a look the following link:

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

Regards
 

Open Exchange applications:
Certifications & Credly badges:
Global Masters badges:
Followers:
Following: