diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index 4a3240d2a2a1fecec13fb1ae51885a062ac5a0f2..95fda3cf3d7deb6d20fcc8d858d3c2b2acbebd52 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -377,6 +377,35 @@ SqlCondition.prototype._init = function() { //init only wraps the clear function to avoid confusion in the constructor (and provide better extensibility) return this.clear(); } + +// some static functions for often used tasks. They are only provided for very simple tasks. + +/** + * pField = pValue + * @param {String} pField the database field as "tablename.columnname"; e.g. "ORG.NAME" + * @param {String} pValue the value that shall be set into the prepared statement + * @param {String} [pAlternativeCond=""] Condition that is returned when nothing has been appended. + * @param {String} [pAlias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements) + * + * @return {Array[][][]} Prepared condition with [condition, [[field, type]]] + */ +SqlCondition.equals = function(pField, pValue, pAlternativeCond, pAlias) { + return SqlCondition.begin(pAlias).andPrepare(pField, pValue).build(pAlternativeCond); +} + +/** + * pField <> pValue + * @param {String} pField the database field as "tablename.columnname"; e.g. "ORG.NAME" + * @param {String} pValue the value that shall be set into the prepared statement + * @param {String} [pAlternativeCond=""] Condition that is returned when nothing has been appended. + * @param {String} [pAlias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements) + * + * @return {Array[][][]} Prepared condition with [condition, [[field, type]]] + */ +SqlCondition.equalsNot = function(pField, pValue, pAlternativeCond, pAlias) { + return SqlCondition.begin(pAlias).andPrepare(pField, pValue, "# <> ?").build(pAlternativeCond); +} + /** provides functions for masking sql functions *