From 2d647c520a19526911a01b549f8236be79dfe7d9 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 13 Mar 2020 11:32:27 +0100 Subject: [PATCH] IDEMPIERE-4178 Replace NVL with Coalesce / partial revert of commit 2c639f - just the java part --- .../org/compiere/process/ImportInventory.java | 4 +- .../org/compiere/process/InventoryValue.java | 4 +- .../process/SynchronizeTerminology.java | 48 +++++++++---------- .../org/compiere/process/TransactionXRef.java | 6 +-- .../src/org/compiere/model/GridTab.java | 2 +- .../src/org/compiere/model/MBOMProduct.java | 2 +- .../org/compiere/model/MDunningRunLine.java | 2 +- .../org/compiere/model/MInvoiceBatchLine.java | 2 +- .../src/org/compiere/model/MLanguage.java | 2 +- .../org/compiere/model/MLookupFactory.java | 14 +++--- .../src/org/compiere/model/MRecentItem.java | 8 ++-- .../compiere/process/ServerProcessCtl.java | 4 +- .../globalqss/process/CopyFromCashPlan.java | 2 +- .../GeneratePeriodicCashPlanLines.java | 2 +- .../fa/process/ImportFixedAsset.java | 2 +- .../adempiere/webui/util/UserPreference.java | 4 +- .../src/org/compiere/apps/form/Match.java | 8 ++-- .../org/compiere/grid/CreateFromShipment.java | 2 +- .../org/compiere/grid/PaymentFormDirect.java | 2 +- 19 files changed, 60 insertions(+), 60 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java index 54de387771..b5e66cdaed 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInventory.java @@ -321,7 +321,7 @@ public class ImportInventory extends SvrProcess implements ImportProcess // Excluding quantities sql = new StringBuilder ("UPDATE I_Inventory ") .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Excluding quantities, ' ") - .append("WHERE COALESCE(QtyInternalUse,0)<>0 AND (COALESCE(QtyCount,0)<>0 OR COALESCE(QtyBook,0)<>0) ") + .append("WHERE NVL(QtyInternalUse,0)<>0 AND (NVL(QtyCount,0)<>0 OR NVL(QtyBook,0)<>0) ") .append(" AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate (sql.toString (), get_TrxName()); if (no != 0) @@ -330,7 +330,7 @@ public class ImportInventory extends SvrProcess implements ImportProcess // Required charge for internal use sql = new StringBuilder ("UPDATE I_Inventory ") .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Required charge, ' ") - .append("WHERE COALESCE(QtyInternalUse,0)<>0 AND COALESCE(C_Charge_ID,0)=0 ") + .append("WHERE NVL(QtyInternalUse,0)<>0 AND NVL(C_Charge_ID,0)=0 ") .append(" AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate (sql.toString (), get_TrxName()); if (no != 0) diff --git a/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java b/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java index 78f9f2e1ab..999c031b08 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java +++ b/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java @@ -201,7 +201,7 @@ public class InventoryValue extends SvrProcess // Adjust for Valuation Date sql = new StringBuilder("UPDATE T_InventoryValue iv ") .append("SET QtyOnHand=") - .append("(SELECT iv.QtyOnHand - COALESCE(SUM(t.MovementQty), 0) ") + .append("(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) ") .append("FROM M_Transaction t") .append(" INNER JOIN M_Locator l ON (t.M_Locator_ID=l.M_Locator_ID) ") .append("WHERE t.M_Product_ID=iv.M_Product_ID") @@ -215,7 +215,7 @@ public class InventoryValue extends SvrProcess // sql = new StringBuilder("UPDATE T_InventoryValue iv ") .append("SET QtyOnHand=") - .append("(SELECT iv.QtyOnHand - COALESCE(SUM(t.MovementQty), 0) ") + .append("(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) ") .append("FROM M_Transaction t") .append(" INNER JOIN M_Locator l ON (t.M_Locator_ID=l.M_Locator_ID) ") .append("WHERE t.M_Product_ID=iv.M_Product_ID") diff --git a/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java b/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java index 03db554bb1..b607966766 100644 --- a/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java +++ b/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java @@ -141,8 +141,8 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE EXISTS (SELECT 1 FROM AD_ELEMENT e " +" WHERE c.AD_Element_ID=e.AD_Element_ID" +" AND (c.ColumnName <> e.ColumnName OR c.Name <> e.Name " - +" OR COALESCE(c.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(c.Help,' ') <> COALESCE(e.Help,' ')" - +" OR COALESCE(c.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))"; + +" OR NVL(c.Description,' ') <> NVL(e.Description,' ') OR NVL(c.Help,' ') <> NVL(e.Help,' ')" + +" OR NVL(c.Placeholder,' ') <> NVL(e.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -158,8 +158,8 @@ public class SynchronizeTerminology extends SvrProcess +" AND EXISTS (SELECT 1 FROM AD_ELEMENT e " +" WHERE c.AD_Element_ID=e.AD_Element_ID" +" AND (c.ColumnName <> e.ColumnName OR c.Name <> e.Name " - +" OR COALESCE(c.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(c.Help,' ') <> COALESCE(e.Help,' ')" - +" OR COALESCE(c.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))"; + +" OR NVL(c.Description,' ') <> NVL(e.Description,' ') OR NVL(c.Help,' ') <> NVL(e.Help,' ')" + +" OR NVL(c.Placeholder,' ') <> NVL(e.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -176,8 +176,8 @@ public class SynchronizeTerminology extends SvrProcess +" AND EXISTS (SELECT 1 FROM AD_ELEMENT e, AD_COLUMN c" +" WHERE f.AD_Column_ID=c.AD_Column_ID" +" AND c.AD_Element_ID=e.AD_Element_ID AND c.AD_Process_ID IS NULL" - +" AND (f.Name <> e.Name OR COALESCE(f.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(f.Help,' ') <> COALESCE(e.Help,' ')" - +" OR COALESCE(f.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))"; + +" AND (f.Name <> e.Name OR NVL(f.Description,' ') <> NVL(e.Description,' ') OR NVL(f.Help,' ') <> NVL(e.Help,' ')" + +" OR NVL(f.Placeholder,' ') <> NVL(e.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -207,8 +207,8 @@ public class SynchronizeTerminology extends SvrProcess +" AND c.AD_Element_ID=e.AD_Element_ID AND c.AD_Process_ID IS NULL" +" AND trl.AD_LANGUAGE=e.AD_LANGUAGE" +" AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" - +" AND (trl.Name <> e.Name OR COALESCE(trl.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(trl.Help,' ') <> COALESCE(e.Help,' ')" - +" OR COALESCE(trl.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))"; + +" AND (trl.Name <> e.Name OR NVL(trl.Description,' ') <> NVL(e.Description,' ') OR NVL(trl.Help,' ') <> NVL(e.Help,' ')" + +" OR NVL(trl.Placeholder,' ') <> NVL(e.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -227,7 +227,7 @@ public class SynchronizeTerminology extends SvrProcess +" AND EXISTS (SELECT 1 FROM AD_ELEMENT e, AD_COLUMN c" +" WHERE f.AD_Column_ID=c.AD_Column_ID" +" AND c.AD_Element_ID=e.AD_Element_ID AND c.AD_Process_ID IS NULL" - +" AND (f.Name <> e.PO_Name OR COALESCE(f.Description,' ') <> COALESCE(e.PO_Description,' ') OR COALESCE(f.Help,' ') <> COALESCE(e.PO_Help,' '))" + +" AND (f.Name <> e.PO_Name OR NVL(f.Description,' ') <> NVL(e.PO_Description,' ') OR NVL(f.Help,' ') <> NVL(e.PO_Help,' '))" +" AND e.PO_Name IS NOT NULL)" +" AND EXISTS (SELECT 1 FROM AD_TAB t, AD_WINDOW w" +" WHERE f.AD_Tab_ID=t.AD_Tab_ID" @@ -259,7 +259,7 @@ public class SynchronizeTerminology extends SvrProcess +" AND c.AD_Element_ID=e.AD_Element_ID AND c.AD_Process_ID IS NULL" +" AND trl.AD_LANGUAGE=e.AD_LANGUAGE" +" AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" - +" AND (trl.Name <> e.PO_Name OR COALESCE(trl.Description,' ') <> COALESCE(e.PO_Description,' ') OR COALESCE(trl.Help,' ') <> COALESCE(e.PO_Help,' '))" + +" AND (trl.Name <> e.PO_Name OR NVL(trl.Description,' ') <> NVL(e.PO_Description,' ') OR NVL(trl.Help,' ') <> NVL(e.PO_Help,' '))" +" AND e.PO_Name IS NOT NULL)" +" AND EXISTS (SELECT 1 FROM AD_FIELD f, AD_TAB t, AD_WINDOW w" +" WHERE trl.AD_Field_ID=f.AD_Field_ID" @@ -283,7 +283,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" +" AND EXISTS (SELECT 1 FROM AD_PROCESS p, AD_COLUMN c" +" WHERE c.AD_Process_ID=p.AD_Process_ID AND f.AD_Column_ID=c.AD_Column_ID" - +" AND (f.Name<>p.Name OR COALESCE(f.Description,' ')<>COALESCE(p.Description,' ') OR COALESCE(f.Help,' ')<>COALESCE(p.Help,' ')))"; + +" AND (f.Name<>p.Name OR NVL(f.Description,' ')<>NVL(p.Description,' ') OR NVL(f.Help,' ')<>NVL(p.Help,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -308,7 +308,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE c.AD_Process_ID=p.AD_Process_ID AND f.AD_Column_ID=c.AD_Column_ID" +" AND f.AD_Field_ID=trl.AD_Field_ID AND p.AD_LANGUAGE=trl.AD_LANGUAGE" +" AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" - +" AND (trl.Name<>p.Name OR COALESCE(trl.Description,' ')<>COALESCE(p.Description,' ') OR COALESCE(trl.Help,' ')<>COALESCE(p.Help,' ')))"; + +" AND (trl.Name<>p.Name OR NVL(trl.Description,' ')<>NVL(p.Description,' ') OR NVL(trl.Help,' ')<>NVL(p.Help,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -350,7 +350,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" +" AND EXISTS (SELECT 1 FROM AD_ELEMENT e" +" WHERE e.ColumnName=f.ColumnName" - +" AND (f.Name <> e.Name OR COALESCE(f.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(f.Help,' ') <> COALESCE(e.Help,' ') OR COALESCE(f.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))"; + +" AND (f.Name <> e.Name OR NVL(f.Description,' ') <> NVL(e.Description,' ') OR NVL(f.Help,' ') <> NVL(e.Help,' ') OR NVL(f.Placeholder,' ') <> NVL(e.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -378,7 +378,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE et.AD_LANGUAGE=trl.AD_LANGUAGE AND et.AD_Element_ID=e.AD_Element_ID" +" AND e.ColumnName=f.ColumnName AND f.AD_Process_Para_ID=trl.AD_Process_Para_ID" +" AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" - +" AND (trl.Name <> et.Name OR COALESCE(trl.Description,' ') <> COALESCE(et.Description,' ') OR COALESCE(trl.Help,' ') <> COALESCE(et.Help,' ') OR COALESCE(trl.Placeholder,' ') <> COALESCE(et.Placeholder,' ')))"; + +" AND (trl.Name <> et.Name OR NVL(trl.Description,' ') <> NVL(et.Description,' ') OR NVL(trl.Help,' ') <> NVL(et.Help,' ') OR NVL(trl.Placeholder,' ') <> NVL(et.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -406,7 +406,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE et.AD_LANGUAGE=trl.AD_LANGUAGE AND et.AD_Element_ID=e.AD_Element_ID" +" AND e.ColumnName=f.ColumnName AND f.AD_InfoColumn_ID=trl.AD_InfoColumn_ID" +" AND f.IsCentrallyMaintained='Y' AND f.IsActive='Y'" - +" AND (trl.Name <> et.Name OR COALESCE(trl.Description,' ') <> COALESCE(et.Description,' ') OR COALESCE(trl.Help,' ') <> COALESCE(et.Help,' ') OR COALESCE(trl.Placeholder,' ') <> COALESCE(et.Placeholder,' ')))"; + +" AND (trl.Name <> et.Name OR NVL(trl.Description,' ') <> NVL(et.Description,' ') OR NVL(trl.Help,' ') <> NVL(et.Help,' ') OR NVL(trl.Placeholder,' ') <> NVL(et.Placeholder,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -423,7 +423,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE n.IsCentrallyMaintained = 'Y'" +" AND EXISTS (SELECT 1 FROM AD_WINDOW w" +" WHERE w.AD_Window_ID=n.AD_Window_ID" - +" AND (w.Name <> n.Name OR COALESCE(w.Description,' ') <> COALESCE(n.Description,' ') OR COALESCE(w.Help,' ') <> COALESCE(" + +" AND (w.Name <> n.Name OR NVL(w.Description,' ') <> NVL(n.Description,' ') OR NVL(w.Help,' ') <> NVL(" + (DB.isOracle() ? "dbms_lob.substr(n.Help, 4000, 1 )" : "n.Help") +",' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); @@ -445,9 +445,9 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE EXISTS (SELECT 1 FROM AD_WINDOW_TRL t, AD_WF_NODE n" +" WHERE trl.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Window_ID=t.AD_Window_ID" +" AND trl.AD_LANGUAGE=t.AD_LANGUAGE AND n.IsCentrallyMaintained='Y' AND n.IsActive='Y'" - +" AND (trl.Name <> t.Name OR COALESCE(trl.Description,' ') <> COALESCE(t.Description,' ') OR COALESCE(" + +" AND (trl.Name <> t.Name OR NVL(trl.Description,' ') <> NVL(t.Description,' ') OR NVL(" + (DB.isOracle() ? "dbms_lob.substr(trl.Help, 4000, 1 )" : "trl.Help") - +",' ') <> COALESCE(t.Help,' ')))"; + +",' ') <> NVL(t.Help,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -461,7 +461,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE n.IsCentrallyMaintained = 'Y'" +" AND EXISTS (SELECT 1 FROM AD_FORM f" +" WHERE f.AD_Form_ID=n.AD_Form_ID" - +" AND (f.Name <> n.Name OR COALESCE(f.Description,' ') <> COALESCE(n.Description,' ') OR COALESCE(f.Help,' ') <> COALESCE(" + +" AND (f.Name <> n.Name OR NVL(f.Description,' ') <> NVL(n.Description,' ') OR NVL(f.Help,' ') <> NVL(" + (DB.isOracle() ? "dbms_lob.substr(n.Help, 4000, 1 )" : "n.Help") +",' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); @@ -478,9 +478,9 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE EXISTS (SELECT 1 FROM AD_FORM_TRL t, AD_WF_NODE n" +" WHERE trl.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Form_ID=t.AD_Form_ID" +" AND trl.AD_LANGUAGE=t.AD_LANGUAGE AND n.IsCentrallyMaintained='Y' AND n.IsActive='Y'" - +" AND (trl.Name <> t.Name OR COALESCE(trl.Description,' ') <> COALESCE(t.Description,' ') OR COALESCE(" + +" AND (trl.Name <> t.Name OR NVL(trl.Description,' ') <> NVL(t.Description,' ') OR NVL(" + (DB.isOracle() ? "dbms_lob.substr(trl.Help, 4000, 1 )" : "trl.Help") - +",' ') <> COALESCE(t.Help,' ')))"; + +",' ') <> NVL(t.Help,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); @@ -494,7 +494,7 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE n.IsCentrallyMaintained = 'Y'" +" AND EXISTS (SELECT 1 FROM AD_PROCESS f" +" WHERE f.AD_Process_ID=n.AD_Process_ID" - +" AND (f.Name <> n.Name OR COALESCE(f.Description,' ') <> COALESCE(n.Description,' ') OR COALESCE(f.Help,' ') <> COALESCE(" + +" AND (f.Name <> n.Name OR NVL(f.Description,' ') <> NVL(n.Description,' ') OR NVL(f.Help,' ') <> NVL(" + (DB.isOracle() ? "dbms_lob.substr(n.Help, 4000, 1 )" : "n.Help") +",' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); @@ -511,9 +511,9 @@ public class SynchronizeTerminology extends SvrProcess +" WHERE EXISTS (SELECT 1 FROM AD_PROCESS_TRL t, AD_WF_NODE n" +" WHERE trl.AD_WF_Node_ID=n.AD_WF_Node_ID AND n.AD_Process_ID=t.AD_Process_ID" +" AND trl.AD_LANGUAGE=t.AD_LANGUAGE AND n.IsCentrallyMaintained='Y' AND n.IsActive='Y'" - +" AND (trl.Name <> t.Name OR COALESCE(trl.Description,' ') <> COALESCE(t.Description,' ') OR COALESCE(" + +" AND (trl.Name <> t.Name OR NVL(trl.Description,' ') <> NVL(t.Description,' ') OR NVL(" + (DB.isOracle() ? "dbms_lob.substr(trl.Help, 4000, 1 )" : "trl.Help") - +",' ') <> COALESCE(t.Help,' ')))"; + +",' ') <> NVL(t.Help,' ')))"; no = DB.executeUpdate(sql, false, get_TrxName()); if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); diff --git a/org.adempiere.base.process/src/org/compiere/process/TransactionXRef.java b/org.adempiere.base.process/src/org/compiere/process/TransactionXRef.java index 72154368e4..71e661a3e1 100644 --- a/org.adempiere.base.process/src/org/compiere/process/TransactionXRef.java +++ b/org.adempiere.base.process/src/org/compiere/process/TransactionXRef.java @@ -68,7 +68,7 @@ public class TransactionXRef extends SvrProcess // if (p_Search_InOut_ID != 0){ StringBuilder msgtrx = new StringBuilder( - "SELECT COALESCE(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ") + "SELECT NVL(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ") .append("FROM M_InOutLine iol") .append(" LEFT OUTER JOIN M_InOutLineMA ma ON (iol.M_InOutLine_ID=ma.M_InOutLine_ID) ") .append("WHERE M_InOut_ID=").append(p_Search_InOut_ID); @@ -76,7 +76,7 @@ public class TransactionXRef extends SvrProcess } else if (p_Search_Order_ID != 0){ StringBuilder msgtrx = new StringBuilder( - "SELECT COALESCE(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ") + "SELECT NVL(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ") .append("FROM M_InOutLine iol") .append(" LEFT OUTER JOIN M_InOutLineMA ma ON (iol.M_InOutLine_ID=ma.M_InOutLine_ID) ") .append(" INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)") @@ -85,7 +85,7 @@ public class TransactionXRef extends SvrProcess } else if (p_Search_Invoice_ID != 0){ StringBuilder msgtrx = new StringBuilder( - "SELECT COALESCE(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ") + "SELECT NVL(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ") .append("FROM M_InOutLine iol") .append(" LEFT OUTER JOIN M_InOutLineMA ma ON (iol.M_InOutLine_ID=ma.M_InOutLine_ID) ") .append(" INNER JOIN C_InvoiceLine il ON (iol.M_InOutLine_ID=il.M_InOutLine_ID) ") diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index b3365951d5..002b03d684 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -1809,7 +1809,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable Object[] arguments = new Object[3]; boolean filled = false; // - String sql = "SELECT COUNT(*), COALESCE(SUM(LineNetAmt),0), COALESCE(SUM(LineTotalAmt),0) " + String sql = "SELECT COUNT(*), NVL(SUM(LineNetAmt),0), NVL(SUM(LineTotalAmt),0) " + "FROM C_InvoiceBatchLine " + "WHERE C_InvoiceBatch_ID=? AND IsActive='Y'"; // diff --git a/org.adempiere.base/src/org/compiere/model/MBOMProduct.java b/org.adempiere.base/src/org/compiere/model/MBOMProduct.java index d6bad58ac3..bbde8c3dbd 100644 --- a/org.adempiere.base/src/org/compiere/model/MBOMProduct.java +++ b/org.adempiere.base/src/org/compiere/model/MBOMProduct.java @@ -190,7 +190,7 @@ public class MBOMProduct extends X_M_BOMProduct // Set Line Number if (getLine() == 0) { - String sql = "SELECT COALESCE(MAX(Line),0)+10 FROM M_BOMProduct WHERE M_BOM_ID=?"; + String sql = "SELECT NVL(MAX(Line),0)+10 FROM M_BOMProduct WHERE M_BOM_ID=?"; int ii = DB.getSQLValue (get_TrxName(), sql, getM_BOM_ID()); setLine (ii); } diff --git a/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java b/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java index d9db222482..8456f54556 100644 --- a/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java +++ b/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java @@ -345,7 +345,7 @@ public class MDunningRunLine extends X_C_DunningRunLine { // we do not count the fee line as an item, but it sum it up. StringBuilder sql = new StringBuilder("UPDATE C_DunningRunEntry e ") - .append("SET Amt=COALESCE((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)") + .append("SET Amt=NVL((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)") .append(" FROM C_DunningRunLine l ") .append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID), 0), ") .append("QTY=(SELECT COUNT(*)") diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java index 8a278eeb4a..76fb56d569 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java @@ -112,7 +112,7 @@ public class MInvoiceBatchLine extends X_C_InvoiceBatchLine if (success) { StringBuilder sql = new StringBuilder("UPDATE C_InvoiceBatch h ") - .append("SET DocumentAmt = COALESCE((SELECT SUM(LineTotalAmt) FROM C_InvoiceBatchLine l ") + .append("SET DocumentAmt = NVL((SELECT SUM(LineTotalAmt) FROM C_InvoiceBatchLine l ") .append("WHERE h.C_InvoiceBatch_ID=l.C_InvoiceBatch_ID AND l.IsActive='Y'),0) ") .append("WHERE C_InvoiceBatch_ID=").append(getC_InvoiceBatch_ID()); DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MLanguage.java b/org.adempiere.base/src/org/compiere/model/MLanguage.java index d669af2c20..498b568f6c 100644 --- a/org.adempiere.base/src/org/compiere/model/MLanguage.java +++ b/org.adempiere.base/src/org/compiere/model/MLanguage.java @@ -260,7 +260,7 @@ public class MLanguage extends X_AD_Language int AD_Language_ID = getAD_Language_ID(); if (AD_Language_ID == 0) { - String sql = "SELECT COALESCE(MAX(AD_Language_ID), 999999) FROM AD_Language WHERE AD_Language_ID > 1000"; + String sql = "SELECT NVL(MAX(AD_Language_ID), 999999) FROM AD_Language WHERE AD_Language_ID > 1000"; AD_Language_ID = DB.getSQLValue (get_TrxName(), sql); setAD_Language_ID(AD_Language_ID+1); } diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index 92c95062bf..fc62fa2ca3 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -500,9 +500,9 @@ public class MLookupFactory if (KeyColumn.endsWith("_ID")) realSQL.append("NULL,"); if (isValueDisplayed) - realSQL.append("COALESCE(").append(TableName).append(".Value,'-1') || '-' || "); + realSQL.append("NVL(").append(TableName).append(".Value,'-1') || '-' || "); if (displayColumnSQL != null && displayColumnSQL.trim().length() > 0) - realSQL.append("COALESCE(").append(displayColumnSQL).append(",'-1')"); + realSQL.append("NVL(").append(displayColumnSQL).append(",'-1')"); else { if (showID) { StringBuilder displayColumn = getDisplayColumn(language, TableName, list); @@ -510,7 +510,7 @@ public class MLookupFactory realSQL.append(displayColumn); } else { lookupDisplayColumn = DisplayColumn; - realSQL.append("COALESCE(").append(TableName).append("_Trl.").append(DisplayColumn).append(",'-1')"); + realSQL.append("NVL(").append(TableName).append("_Trl.").append(DisplayColumn).append(",'-1')"); } } realSQL.append(",").append(TableName).append(".IsActive"); @@ -528,9 +528,9 @@ public class MLookupFactory if (KeyColumn.endsWith("_ID")) realSQL.append("NULL,"); if (isValueDisplayed) - realSQL.append("COALESCE(").append(TableName).append(".Value,'-1') || '-' || "); + realSQL.append("NVL(").append(TableName).append(".Value,'-1') || '-' || "); if (displayColumnSQL != null && displayColumnSQL.trim().length() > 0) - realSQL.append("COALESCE(").append(displayColumnSQL).append(",'-1')"); + realSQL.append("NVL(").append(displayColumnSQL).append(",'-1')"); else { if (showID) { StringBuilder displayColumn = getDisplayColumn(language, TableName, list); @@ -538,7 +538,7 @@ public class MLookupFactory realSQL.append(displayColumn); } else { lookupDisplayColumn = DisplayColumn; - realSQL.append("COALESCE(").append(TableName).append(".").append(DisplayColumn).append(",'-1')"); + realSQL.append("NVL(").append(TableName).append(".").append(DisplayColumn).append(",'-1')"); } } realSQL.append(",").append(TableName).append(".IsActive"); @@ -847,7 +847,7 @@ public class MLookupFactory StringBuilder msg = new StringBuilder().append(TableName).append(".").append(ldc.ColumnName); String columnSQL = ldc.IsVirtual ? ldc.ColumnSQL : msg.toString(); - displayColumn.append("COALESCE("); + displayColumn.append("NVL("); // translated if (ldc.IsTranslated && !Env.isBaseLanguage(language, TableName) && !ldc.IsVirtual diff --git a/org.adempiere.base/src/org/compiere/model/MRecentItem.java b/org.adempiere.base/src/org/compiere/model/MRecentItem.java index 1289428b11..dea7a16cc6 100644 --- a/org.adempiere.base/src/org/compiere/model/MRecentItem.java +++ b/org.adempiere.base/src/org/compiere/model/MRecentItem.java @@ -140,7 +140,7 @@ public class MRecentItem extends X_AD_RecentItem } // MRecentItem retValue = null; - String sql = "SELECT * FROM AD_RecentItem WHERE AD_Table_ID=? AND Record_ID=? AND COALESCE(AD_User_ID,0)=?"; + String sql = "SELECT * FROM AD_RecentItem WHERE AD_Table_ID=? AND Record_ID=? AND NVL(AD_User_ID,0)=?"; PreparedStatement pstmt = null; ResultSet rs = null; try @@ -239,10 +239,10 @@ public class MRecentItem extends X_AD_RecentItem int maxri = MSysConfig.getIntValue(MSysConfig.RecentItems_MaxSaved, 50, AD_Client_ID); if (maxri < 0) maxri = 0; - int cntri = DB.getSQLValue(null, "SELECT COUNT(*) FROM AD_RecentItem WHERE COALESCE(AD_User_ID,0)=? AND AD_Client_ID=?", AD_User_ID, AD_Client_ID); + int cntri = DB.getSQLValue(null, "SELECT COUNT(*) FROM AD_RecentItem WHERE NVL(AD_User_ID,0)=? AND AD_Client_ID=?", AD_User_ID, AD_Client_ID); if (cntri > maxri) { int cntdel = cntri - maxri; - String sql = "SELECT AD_Table_ID, Record_ID FROM AD_RecentItem WHERE COALESCE(AD_User_ID,0)=? AND AD_Client_ID=? ORDER BY Updated"; + String sql = "SELECT AD_Table_ID, Record_ID FROM AD_RecentItem WHERE NVL(AD_User_ID,0)=? AND AD_Client_ID=? ORDER BY Updated"; PreparedStatement pstmt = null; ResultSet rs = null; try @@ -282,7 +282,7 @@ public class MRecentItem extends X_AD_RecentItem } public static List getFromUser(Properties ctx, int AD_User_ID) { - int[] ids = new Query(ctx, MRecentItem.Table_Name, "COALESCE(AD_User_ID,0)=?", null) + int[] ids = new Query(ctx, MRecentItem.Table_Name, "NVL(AD_User_ID,0)=?", null) .setOnlyActiveRecords(true) .setClient_ID() .setParameters(AD_User_ID) diff --git a/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java b/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java index 8b5f6399e3..096e78df8a 100644 --- a/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java +++ b/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java @@ -139,7 +139,7 @@ public class ServerProcessCtl implements Runnable { // String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 - + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," // 9 + + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE," // 9 + " p.IsServerProcess, p.JasperReport, p.AD_Process_UU " // 10..12 + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " @@ -148,7 +148,7 @@ public class ServerProcessCtl implements Runnable { if (!Env.isBaseLanguage(Env.getCtx(), "AD_Process")) sql = "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 - + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," // 9 + + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE," // 9 + " p.IsServerProcess, p.JasperReport, p.AD_Process_UU " // 10..12 + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " diff --git a/org.adempiere.base/src/org/globalqss/process/CopyFromCashPlan.java b/org.adempiere.base/src/org/globalqss/process/CopyFromCashPlan.java index 48934dd2ab..5b3a38c593 100644 --- a/org.adempiere.base/src/org/globalqss/process/CopyFromCashPlan.java +++ b/org.adempiere.base/src/org/globalqss/process/CopyFromCashPlan.java @@ -59,7 +59,7 @@ public class CopyFromCashPlan extends SvrProcess { throw new IllegalArgumentException ("Source Cash Plan does not exist"); int insertNo = 0; - int lineNo = DB.getSQLValue(get_TrxName(), "SELECT COALESCE(MAX(Line),0)+10 FROM C_CashPlanLine WHERE C_CashPlan_ID=?", p_C_CashPlanTarget_ID); + int lineNo = DB.getSQLValue(get_TrxName(), "SELECT NVL(MAX(Line),0)+10 FROM C_CashPlanLine WHERE C_CashPlan_ID=?", p_C_CashPlanTarget_ID); for (MCashPlanLine cpls : cpsource.getLines()) { MCashPlanLine cplt = new MCashPlanLine(getCtx(), 0, get_TrxName()); diff --git a/org.adempiere.base/src/org/globalqss/process/GeneratePeriodicCashPlanLines.java b/org.adempiere.base/src/org/globalqss/process/GeneratePeriodicCashPlanLines.java index 3dfad3fa8e..8d8c092b35 100644 --- a/org.adempiere.base/src/org/globalqss/process/GeneratePeriodicCashPlanLines.java +++ b/org.adempiere.base/src/org/globalqss/process/GeneratePeriodicCashPlanLines.java @@ -129,7 +129,7 @@ public class GeneratePeriodicCashPlanLines extends SvrProcess { throw new IllegalArgumentException ("Cash Plan does not exist"); int insertNo = 0; - int lineNo = DB.getSQLValue(get_TrxName(), "SELECT COALESCE(MAX(Line),0)+10 FROM C_CashPlanLine WHERE C_CashPlan_ID=?", p_C_CashPlan_ID); + int lineNo = DB.getSQLValue(get_TrxName(), "SELECT NVL(MAX(Line),0)+10 FROM C_CashPlanLine WHERE C_CashPlan_ID=?", p_C_CashPlan_ID); for (int cnt = 0; cnt < p_Repetitions; cnt++) { MCashPlanLine cpl = new MCashPlanLine(getCtx(), 0, get_TrxName()); diff --git a/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java b/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java index 900c1d6925..0ab432a874 100644 --- a/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java +++ b/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java @@ -338,7 +338,7 @@ public class ImportFixedAsset extends SvrProcess int cnt_ok = 0; int cnt_err = 0; - String whereClause = "COALESCE(I_IsImported,'N')='N'"+sqlCheck; + String whereClause = "NVL(I_IsImported,'N')='N'"+sqlCheck; POResultSet rs = new Query(getCtx(), X_I_FixedAsset.Table_Name, whereClause, get_TrxName()) .scroll(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/UserPreference.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/UserPreference.java index d4026c0007..bf5f67edea 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/UserPreference.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/UserPreference.java @@ -104,7 +104,7 @@ public final class UserPreference implements Serializable { */ public void savePreference() { if (m_AD_User_ID >= 0) { - Query query = new Query(Env.getCtx(), I_AD_Preference.Table_Name, "COALESCE(AD_User_ID,0) = ? AND Attribute = ? AND AD_Window_ID Is NULL AND AD_Process_ID IS NULL AND PreferenceFor = 'W'", null); + Query query = new Query(Env.getCtx(), I_AD_Preference.Table_Name, "NVL(AD_User_ID,0) = ? AND Attribute = ? AND AD_Window_ID Is NULL AND AD_Process_ID IS NULL AND PreferenceFor = 'W'", null); for (int i = 0; i < PROPERTIES.length; i++) { String attribute = PROPERTIES[i]; String value = props.getProperty(attribute); @@ -134,7 +134,7 @@ public final class UserPreference implements Serializable { m_AD_User_ID = AD_User_ID; props = new Properties(); - Query query = new Query(Env.getCtx(), I_AD_Preference.Table_Name, "COALESCE(AD_User_ID,0) = ? AND Attribute = ? AND AD_Window_ID Is NULL AND AD_Process_ID IS NULL AND PreferenceFor = 'W'", null); + Query query = new Query(Env.getCtx(), I_AD_Preference.Table_Name, "NVL(AD_User_ID,0) = ? AND Attribute = ? AND AD_Window_ID Is NULL AND AD_Process_ID IS NULL AND PreferenceFor = 'W'", null); for (int i = 0; i < PROPERTIES.length; i++) { String attribute = PROPERTIES[i]; diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Match.java b/org.adempiere.ui/src/org/compiere/apps/form/Match.java index ce48918046..8d26b8fd8b 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Match.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Match.java @@ -300,7 +300,7 @@ public class Match m_qtyColumn = "lin.QtyInvoiced"; m_sql.append("SELECT hdr.C_Invoice_ID,hdr.DocumentNo, hdr.DateInvoiced, bp.Name,hdr.C_BPartner_ID," + " lin.Line,lin.C_InvoiceLine_ID, p.Name,lin.M_Product_ID," - + " CASE WHEN dt.DocBaseType='APC' THEN lin.QtyInvoiced * -1 ELSE lin.QtyInvoiced END,SUM(COALESCE(mi.Qty,0)), org.Name, hdr.AD_Org_ID " //JAVIER + + " CASE WHEN dt.DocBaseType='APC' THEN lin.QtyInvoiced * -1 ELSE lin.QtyInvoiced END,SUM(NVL(mi.Qty,0)), org.Name, hdr.AD_Org_ID " //JAVIER + "FROM C_Invoice hdr" + " INNER JOIN AD_Org org ON (hdr.AD_Org_ID=org.AD_Org_ID)" //JAVIER + " INNER JOIN C_BPartner bp ON (hdr.C_BPartner_ID=bp.C_BPartner_ID)" @@ -316,7 +316,7 @@ public class Match + " lin.Line,lin.C_InvoiceLine_ID,p.Name,lin.M_Product_ID,dt.DocBaseType,lin.QtyInvoiced, org.Name, hdr.AD_Org_ID " //JAVIER + "HAVING " + (matched ? "0" : "CASE WHEN dt.DocBaseType='APC' THEN lin.QtyInvoiced * -1 ELSE lin.QtyInvoiced END") - + "<>SUM(COALESCE(mi.Qty,0))"; + + "<>SUM(NVL(mi.Qty,0))"; } else if (display == MATCH_ORDER) { @@ -361,7 +361,7 @@ public class Match m_qtyColumn = "lin.MovementQty"; m_sql.append("SELECT hdr.M_InOut_ID,hdr.DocumentNo, hdr.MovementDate, bp.Name,hdr.C_BPartner_ID," + " lin.Line,lin.M_InOutLine_ID, p.Name,lin.M_Product_ID," - + " lin.MovementQty,SUM(COALESCE(m.Qty,0)),org.Name, hdr.AD_Org_ID " //JAVIER + + " lin.MovementQty,SUM(NVL(m.Qty,0)),org.Name, hdr.AD_Org_ID " //JAVIER + "FROM M_InOut hdr" + " INNER JOIN AD_Org org ON (hdr.AD_Org_ID=org.AD_Org_ID)" //JAVIER + " INNER JOIN C_BPartner bp ON (hdr.C_BPartner_ID=bp.C_BPartner_ID)" @@ -381,7 +381,7 @@ public class Match + " lin.Line,lin.M_InOutLine_ID,p.Name,lin.M_Product_ID,lin.MovementQty, org.Name, hdr.AD_Org_ID " //JAVIER + "HAVING " + (matched ? "0" : "lin.MovementQty") - + "<>SUM(COALESCE(m.Qty,0))"; + + "<>SUM(NVL(m.Qty,0))"; } // Log.trace(7, "VMatch.tableInit", m_sql + "\n" + m_groupBy); } // tableInit diff --git a/org.adempiere.ui/src/org/compiere/grid/CreateFromShipment.java b/org.adempiere.ui/src/org/compiere/grid/CreateFromShipment.java index 11e9671336..5a11dc9e6a 100644 --- a/org.adempiere.ui/src/org/compiere/grid/CreateFromShipment.java +++ b/org.adempiere.ui/src/org/compiere/grid/CreateFromShipment.java @@ -381,7 +381,7 @@ public abstract class CreateFromShipment extends CreateFrom Vector> data = new Vector>(); StringBuilder sql = new StringBuilder("SELECT " // Entered UOM - + "l.QtyInvoiced-SUM(COALESCE(mi.Qty,0)),l.QtyEntered/l.QtyInvoiced," + + "l.QtyInvoiced-SUM(NVL(mi.Qty,0)),l.QtyEntered/l.QtyInvoiced," + " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4 + " p.M_Locator_ID, loc.Value, " // 5..6 + " l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line," // 7..11 diff --git a/org.adempiere.ui/src/org/compiere/grid/PaymentFormDirect.java b/org.adempiere.ui/src/org/compiere/grid/PaymentFormDirect.java index db91eeedd2..7d5b6efff8 100644 --- a/org.adempiere.ui/src/org/compiere/grid/PaymentFormDirect.java +++ b/org.adempiere.ui/src/org/compiere/grid/PaymentFormDirect.java @@ -77,7 +77,7 @@ public abstract class PaymentFormDirect extends PaymentForm { /** * Load Accounts */ - String SQL = "SELECT a.C_BP_BankAccount_ID, COALESCE(b.Name, ' ')||'_'||COALESCE(a.AccountNo, ' ') AS Acct " + String SQL = "SELECT a.C_BP_BankAccount_ID, NVL(b.Name, ' ')||'_'||NVL(a.AccountNo, ' ') AS Acct " + "FROM C_BP_BankAccount a" + " LEFT OUTER JOIN C_Bank b ON (a.C_Bank_ID=b.C_Bank_ID) " + "WHERE C_BPartner_ID=?"