QueryExecute

Execute an SQL query and returns the results.

Method Signature

QueryExecute(sql=[String], params=[any], options=[struct])

Arguments

Examples

Simple Example

SQL Only Example. Assumes that a default datasource has been specified (by setting the variable this.datasource in Application.bx)

qryResult = queryExecute("SELECT * FROM Employees");

Passing Query Parameters using Struct

Use :structKeyName in your sql then pass a struct with corresponding key names.

qryResult = queryExecute(
  "SELECT * FROM Employees WHERE empid = :empid AND country = :country", 
  {
    country="USA", 
    empid=1
  }
);

Passing Query Parameters using Array

When passing with an array use the ? symbol as a placeholder in your sql

qryResult = queryExecute(
  "SELECT * FROM Employees WHERE empid = ? AND country = ?", 
  [
    1,
    "USA"
  ]
);

Last updated

Logo

Copyright & Register Trademark by Ortus Solutions, Corp & Ortus Software, LLC