You can use sqlLib.constructQuery() to return an SQL condition (to be used with a WHERE statement) based on a dictionary that contains comparison operators and values.
sqlLib.constructQuery( sqlRecord Record inOut, dictionary Dictionary inOut, matchByName BOOLEAN in ) returns (condition STRING)
The following sample program creates a condition string (myCondition) from a customer record and a dictionary.
package com.companyb.gl; record CustomerRecord type SQLRecord {tableNames = [["ADMINISTRATOR.CUSTOMER", "L1"]], keyItems = [customerNumber]} customerNumber STRING {column="C_NUMBER", maxLen=6}; customerName STRING {column="C_NAME", isSQLNullable=yes, maxLen=25}; customerAddr1 STRING {column="C_ADDR1", isSQLNullable=yes, maxLen=25}; customerAddr2 STRING {column="C_ADDR2", isSQLNullable=yes, maxLen=25}; customerAddr3 STRING {column="C_ADDR3", isSQLNullable=yes, maxLen=25}; customerBalance MONEY {column="C_BALANCE", isSQLNullable=yes}; end program calc3 myDictionary Dictionary {}; myCustomer CustomerRecord; myCondition STRING; function main() myDictionary.customerNumber = ">A20045"; myDictionary.customerBalance = "!= 0"; myCondition = sqlLib.constructQuery(myCustomer, myDictionary, YES); prepare stmtID from "SELECT * FROM customer WHERE " + myCondition; get customerArray with stmtID; end // main end // program
The contents of myCondition are "C_NUMBER > 'A20045' AND C_BALANCE <> 0".