Business Process and Data Transformation Language Reference
Execute an embedded SQL SELECT
<sql name="LookUp"> <![CDATA[ SELECT SSN INTO :context.SSN FROM MyApp.PatientTable WHERE PatID = :request.PatID ]]> </sql>
The <sql> element executes an arbitrary embedded SQL SELECT
statement from within the execution of a business process.
The <sql> element is especially powerful for performing lookup operations using tables. For example, suppose the primary request coming into a business process provides a PatId
property that indicates a Patient Identity number, and you need to find the matching Social Security number (SSN) before the business process can perform work. If you have available a PatientTable
table relating PatId
, you can perform the lookup using the following <sql> element:
SELECT SSN INTO :context.SSN
WHERE PatID = :request.PatID
Where the execution context variable context
has an SSN
property that is suitable to receive the result of the SQL query. The execution context variable request
automatically contains the PatId
property, as it always contains the properties received in the primary request object.
If you maintain a local copy of the PatientTable
within the InterSystems IRIS database, the above example is especially efficient, as it can be executed without using any expensive network operations or additional middleware.
To use the <sql> element effectively, keep the following tips in mind:
Always use the fully qualified name of the table, including both the SQL schema name and table name, as in:
The contents of the <sql> element must contain a valid embedded SQL SELECT statement.
It is convenient to place the SQL query within a CDATA block so that you do not have to worry about escaping special XML characters.
Any tables listed in the SQL query’s FROM clause must either be stored within the local InterSystems IRIS database or linked to an external relational database using the SQL Gateway.
SELECT Name INTO :response.Name
WHERE SSN = :request.SSN AND City = :request.Home.City
Only the first row returned by the query will be used. Make sure that your WHERE clause correctly specifies the desired row.
Content Date/Time: 2019-07-19 06:48:24