Sie können 'sqlLib.constructQuery()' verwenden, um eine SQL-Bedingung zurückzugeben (die mit einer Anweisung WHERE verwendet werden soll), die auf einem Wörterverzeichnis basiert, das Vergleichsoperatoren und -werte enthält.
sqlLib.constructQuery(
SQL-Datensatz Record inOut,
Wörterverzeichnis Dictionary inOut,
matchByName BOOLEAN in )
returns (Bedingung STRING)
Das folgende Beispielprogramm erstellt eine Bedingungszeichenfolge (myCondition) aus einem Kundendatensatz (CustomerRecord) und einem Wörterverzeichnis (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 // Ende von 'main'
end // Ende von 'program'
Der Inhalt von myCondition besteht aus Folgendem: "C_NUMBER > 'A20045' AND C_BALANCE <> 0".