Skip to content
Snippets Groups Projects
Commit f6811904 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

refactoring of some SQL-library functions

parent de9ce610
No related branches found
No related tags found
No related merge requests found
......@@ -4,27 +4,13 @@ import("system.result");
import("system.logging");
import("Sql_lib");
var rowId, conditionStr, preparedValues
,sqlHelper;
conditionStr = "";
preparedValues = [];
sqlHelper = new LegacySqlUtils();
var rowId, cond, preparedValues, sqlHelper;
cond = new SqlCondition();
if ((rowId = vars.getString("$param.RowId_param"))){
conditionStr += " and HISTORYLINK.ROW_ID = ? ";
preparedValues.push([rowId, sqlHelper.getSingleColumnType("HISTORYLINK.ROW_ID")]);
rowId = vars.getString("$param.RowId_param");
if (rowId){
cond.andPrepare("HISTORYLINK.ROW_ID", "# = ?", rowId);
}
//TODO; add OBJECT_ID (probably another param)
//conditionStr += " and HISTORYLINK.OBJECT_ID = ? "
//preparedValues.push(["1", sqlHelper.getSingleColumnType("HISTORYLINK.OBJECT_ID")]);
if (conditionStr){
conditionStr = " 1 = 1 " + conditionStr;
result.string(db.translateCondition([conditionStr, preparedValues]));
}
else
result.string("1 = 1");
//TODO: use the preparedStatemenet when available:
//result.object([conditionStr, preparedValues]);
\ No newline at end of file
//TODO: use a preparedCondition when available
result.string(db.translateCondition([cond.toString("1 = 1"), cond.preparedValues]));
\ No newline at end of file
......@@ -4,8 +4,8 @@ import("system.db");
import("Sql_lib");
//TODO: change field to lookup field
var sqlUtils = new LegacySqlUtils();
var prodsSql = "select PRODUCTID, " + sqlUtils.concat(["PRODUCTCODE", "'/'", "PRODUCTNAME"])
var sqlUtils = new SqlMaskingUtils();
var prodsSql = "select PRODUCTID, " + sqlUtils.concat(["PRODUCTCODE", "PRODUCTNAME"], "/")
+ " from PRODUCT";
var prods = db.table(prodsSql);
......
......@@ -3,25 +3,17 @@ import("system.vars");
import("system.result");
import("Sql_lib");
var orgId, conditionStr, preparedValues
,sqlHelper;
conditionStr = "";
preparedValues = [];
sqlHelper = new LegacySqlUtils();
var orgId, cond;
if (vars.exists("$param.OrgId_param") && (orgId = vars.getString("$param.OrgId_param"))){
conditionStr += " and RELATION.ORG_ID = ? ";
preparedValues.push([orgId, sqlHelper.getSingleColumnType("RELATION.ORG_ID")]);
cond = new SqlCondition();
if (vars.exists("$param.OrgId_param")){
orgId = vars.getString("$param.OrgId_param");
if (orgId != "" && orgId != null){
cond.andPrepare("RELATION.ORG_ID", "# = ?", orgId);
}
}
//TODO; add OBJECT_ID (probably another param)
//conditionStr += " and HISTORYLINK.OBJECT_ID = ? "
//preparedValues.push(["1", sqlHelper.getSingleColumnType("HISTORYLINK.OBJECT_ID")]);
if (conditionStr){
conditionStr = " 1 = 1 " + conditionStr;
result.string(db.translateCondition([conditionStr, preparedValues]));
}
else
result.string("1 = 1");
\ No newline at end of file
//TODO: use preparedStatements when available
result.string(db.translateCondition([cond.toString("1 = 1"), cond.preparedValues]));
......@@ -3,14 +3,12 @@ import("system.db");
import("system.vars");
import("Sql_lib");
var orgId, orgRelId, sqlHelper;
var orgId, orgRelId, sqlHelper, cond;
sqlHelper = new LegacySqlUtils();
orgId = vars.get("$field.ORGID");
if (orgId){
orgRelId = db.cell(["select RELATION.RELATIONID from RELATION where RELATION.PERS_ID is null and RELATION.ORG_ID = ?",
[
[orgId, sqlHelper.getSingleColumnType("RELATION", "ORG_ID")]
]]);
cond = new SqlCondition();
cond.and("RELATION.PERS_ID is null").andPrepare("RELATION.ORG_ID", "# = ?", orgId)
orgRelId = db.cell(["select RELATION.RELATIONID from RELATION" + cond.toWhereString(), cond.preparedValues]);
result.string(orgRelId);
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment