Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Input Host Variables in a Dynamic SQL text?

Question
Mike Kadow · Feb 21, 2018

Input Host Variables in a Dynamic SQL text?

I am working my way through some SQL documentation.

The documentation follows and my question comes after.

A query supplied to %Prepare() can contain input host variables, as shown in the following example:

  SET minage = 80

  SET myquery = 3

  SET myquery(1) = "SELECT %ID AS id, Name, DOB, Home_State"

  SET myquery(2) = "FROM Person WHERE Age > :minage"

  SET myquery(3) = "ORDER BY 2"

  SET qStatus = tStatement.%Prepare(.myquery)

This talks about input host variables

I thought that input host variables only work with Embedded SQL, not Dynamic SQL

Thank you

#SQL #Caché

Source URL:https://community.intersystems.com/post/input-host-variables-dynamic-sql-text