Section | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Warning | ||
---|---|---|
| ||
This API requires the Profound.js Connector module. |
Section | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Examples
Load a Grid
Code Block | ||||
---|---|---|---|---|
| ||||
pjs.defineDisplay("display", "mydisplay.json"); var records = pjs.query("SELECT * FROM ORDERS"); display.grid1.replaceRecords(records); |
Retrieve Records by Criteria
Code Block | ||||
---|---|---|---|---|
| ||||
search = '%' + search.trim() + '%'; // adjust for LIKE search var records = pjs.query("SELECT * FROM EMPLOYEES WHERE firstname LIKE ? OR LASTNAME LIKE ?", [search.trim(), search.trim()]); |
Examples with Primitive JavaScript Objects
Retrieve a Description
Code Block | ||||
---|---|---|---|---|
| ||||
var productId = 123; var record = pjs.query("SELECT prdesc FROM PRODUCTS WHERE prid = ?", productId, 1); if (record != null) { var description = record.prdesc; } |
Add a Record
Code Block | ||||
---|---|---|---|---|
| ||||
var record = { id: counter, firstname: fname, lastname: lname } pjs.query("INSERT INTO table SET ?", record); |
Update a Record
Code Block | ||||
---|---|---|---|---|
| ||||
var fieldsToUpdate = {}; fieldsToUpdate.firstname = fname; fieldsToUpdate.lastname = lname; pjs.query("UPDATE table SET ? WHERE id = ?", [ fieldsToUpdate, currentId ]); |
Examples with Strongly Typed Fields
Retrieve a Description
Code Block | ||||
---|---|---|---|---|
| ||||
var productId = 123; pjs.define("prdesc", { type: "char", length: 60 }); pjs.query("SELECT prdesc FROM PRODUCTS WHERE prid = ?", productId, 1, prdesc); var description = prdesc; |
Retrieve Multiple Fields
Code Block | ||||
---|---|---|---|---|
| ||||
var productId = 123; pjs.define("prdesc", { type: "char", length: 60 }); pjs.define("prprice", { type: "packed", length: 7, decimals: 2 }); pjs.query("SELECT * FROM PRODUCTS WHERE prid = ?", productId, 1, prdesc, prrice); |