initMenu_executeQueryExample.js
/*
* This file is part of the xTuple ERP application suite,
* and is Copyright (c) 1999-2019 by OpenMFG LLC, d/b/a xTuple. It
* is licensed to you under the xTuple End-User License Agreement ("the
* EULA"), the full text of which is available at www.xtuple.com/EULA.
* While the EULA gives you access to source code and encourages your
* involvement in the development process, this Package is not free
* software. By using this software, you agree to be bound by the
* terms of the EULA.
*/
/* This is an example script showing query execution and error checking.
This script shows how to execute a simple database query, walk through
the results, and report problems to the user. It is designed to be used
as an initMenu script.
It queries the database for currencies without exchange rates for
the current day. As each row is returned, a message is displayed
for the user.
*/
var fxqry = toolbox.executeQuery("SELECT curr_abbr, curr_rate "
+ " FROM curr_symbol LEFT OUTER JOIN"
+ " curr_rate ON (curr_symbol.curr_id=curr_rate.curr_id"
+ " AND CURRENT_DATE BETWEEN curr_effective AND curr_expires + 1)"
+ " WHERE curr_rate IS NULL;");
while (fxqry.next())
QMessageBox.warning(mainwindow, qsTr("No exchange rate"),
qsTr("%1 has no exchange rate for today.")
.arg(fxqry.value("curr_abbr")));
if (fxqry.lastError().type != QSqlError.NoError)
QMessageBox.critical(mainwindow, qsTr("Database Error"),
qsTr("There was a database error while checking for "
+ "exchange rates during startup:%1")
.arg(fxqry.lastError().text));

Generated on Fri Apr 9 2021 xTuple ERP Programmer Reference, Version 6.0.0 doxygen 1.8.17