Skip to content

Commit

Permalink
IDEMPIERE-4178 Replace NVL with Coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
hengsin committed Feb 21, 2020
1 parent 378ea5f commit 2c639f7
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 60 deletions.
30 changes: 30 additions & 0 deletions db/ddlutils/postgresql/functions/nvl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- IDEMPIERE-4178 Replace NVL with Coalesce
CREATE or REPLACE FUNCTION nvl (anyelement, anyelement ) RETURNS anyelement
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN coalesce($1, $2);
END;
$function$
;

CREATE or REPLACE FUNCTION nvl (numeric, integer ) RETURNS numeric
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN nvl($1, $2::numeric);
END;
$function$
;

CREATE or REPLACE FUNCTION nvl (integer, numeric ) RETURNS numeric
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN nvl($1::numeric, $2);
END;
$function$
;
7 changes: 7 additions & 0 deletions migration/i7.1z/oracle/202002211000_IDEMPIERE-4178.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SET SQLBLANKLINES ON
SET DEFINE OFF

-- IDEMPIERE-4178 Replace NVL with Coalesce
-- PostgreSQL only
SELECT register_migration_script('202002211000_IDEMPIERE-4178.sql') FROM dual
;
33 changes: 33 additions & 0 deletions migration/i7.1z/postgresql/202002211000_IDEMPIERE-4178.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- IDEMPIERE-4178 Replace NVL with Coalesce
CREATE or REPLACE FUNCTION nvl (anyelement, anyelement ) RETURNS anyelement
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN coalesce($1, $2);
END;
$function$
;

CREATE or REPLACE FUNCTION nvl (numeric, integer ) RETURNS numeric
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN nvl($1, $2::numeric);
END;
$function$
;

CREATE or REPLACE FUNCTION nvl (integer, numeric ) RETURNS numeric
LANGUAGE plpgsql
IMMUTABLE
AS $function$
BEGIN
RETURN nvl($1::numeric, $2);
END;
$function$
;

SELECT register_migration_script('202002211000_IDEMPIERE-4178.sql') FROM dual
;
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ protected String doIt() throws java.lang.Exception
// Excluding quantities
sql = new StringBuilder ("UPDATE I_Inventory ")
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Excluding quantities, ' ")
.append("WHERE NVL(QtyInternalUse,0)<>0 AND (NVL(QtyCount,0)<>0 OR NVL(QtyBook,0)<>0) ")
.append("WHERE COALESCE(QtyInternalUse,0)<>0 AND (COALESCE(QtyCount,0)<>0 OR COALESCE(QtyBook,0)<>0) ")
.append(" AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate (sql.toString (), get_TrxName());
if (no != 0)
Expand All @@ -330,7 +330,7 @@ protected String doIt() throws java.lang.Exception
// 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 NVL(QtyInternalUse,0)<>0 AND NVL(C_Charge_ID,0)=0 ")
.append("WHERE COALESCE(QtyInternalUse,0)<>0 AND COALESCE(C_Charge_ID,0)=0 ")
.append(" AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate (sql.toString (), get_TrxName());
if (no != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ protected String doIt() throws Exception
// Adjust for Valuation Date
sql = new StringBuilder("UPDATE T_InventoryValue iv ")
.append("SET QtyOnHand=")
.append("(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) ")
.append("(SELECT iv.QtyOnHand - COALESCE(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")
Expand All @@ -215,7 +215,7 @@ protected String doIt() throws Exception
//
sql = new StringBuilder("UPDATE T_InventoryValue iv ")
.append("SET QtyOnHand=")
.append("(SELECT iv.QtyOnHand - NVL(SUM(t.MovementQty), 0) ")
.append("(SELECT iv.QtyOnHand - COALESCE(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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ protected String doIt() throws Exception
+" 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 NVL(c.Description,' ') <> NVL(e.Description,' ') OR NVL(c.Help,' ') <> NVL(e.Help,' ')"
+" OR NVL(c.Placeholder,' ') <> NVL(e.Placeholder,' ')))";
+" OR COALESCE(c.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(c.Help,' ') <> COALESCE(e.Help,' ')"
+" OR COALESCE(c.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -158,8 +158,8 @@ protected String doIt() throws Exception
+" 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 NVL(c.Description,' ') <> NVL(e.Description,' ') OR NVL(c.Help,' ') <> NVL(e.Help,' ')"
+" OR NVL(c.Placeholder,' ') <> NVL(e.Placeholder,' ')))";
+" OR COALESCE(c.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(c.Help,' ') <> COALESCE(e.Help,' ')"
+" OR COALESCE(c.Placeholder,' ') <> COALESCE(e.Placeholder,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -176,8 +176,8 @@ protected String doIt() throws Exception
+" 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 NVL(f.Description,' ') <> NVL(e.Description,' ') OR NVL(f.Help,' ') <> NVL(e.Help,' ')"
+" OR NVL(f.Placeholder,' ') <> NVL(e.Placeholder,' ')))";
+" 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,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand Down Expand Up @@ -207,8 +207,8 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(e.Description,' ') OR NVL(trl.Help,' ') <> NVL(e.Help,' ')"
+" OR NVL(trl.Placeholder,' ') <> NVL(e.Placeholder,' ')))";
+" 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,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -227,7 +227,7 @@ protected String doIt() throws Exception
+" 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 NVL(f.Description,' ') <> NVL(e.PO_Description,' ') OR NVL(f.Help,' ') <> NVL(e.PO_Help,' '))"
+" AND (f.Name <> e.PO_Name OR COALESCE(f.Description,' ') <> COALESCE(e.PO_Description,' ') OR COALESCE(f.Help,' ') <> COALESCE(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"
Expand Down Expand Up @@ -259,7 +259,7 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(e.PO_Description,' ') OR NVL(trl.Help,' ') <> NVL(e.PO_Help,' '))"
+" AND (trl.Name <> e.PO_Name OR COALESCE(trl.Description,' ') <> COALESCE(e.PO_Description,' ') OR COALESCE(trl.Help,' ') <> COALESCE(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"
Expand All @@ -283,7 +283,7 @@ protected String doIt() throws Exception
+" 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 NVL(f.Description,' ')<>NVL(p.Description,' ') OR NVL(f.Help,' ')<>NVL(p.Help,' ')))";
+" AND (f.Name<>p.Name OR COALESCE(f.Description,' ')<>COALESCE(p.Description,' ') OR COALESCE(f.Help,' ')<>COALESCE(p.Help,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -308,7 +308,7 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ')<>NVL(p.Description,' ') OR NVL(trl.Help,' ')<>NVL(p.Help,' ')))";
+" AND (trl.Name<>p.Name OR COALESCE(trl.Description,' ')<>COALESCE(p.Description,' ') OR COALESCE(trl.Help,' ')<>COALESCE(p.Help,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand Down Expand Up @@ -350,7 +350,7 @@ protected String doIt() throws Exception
+" 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 NVL(f.Description,' ') <> NVL(e.Description,' ') OR NVL(f.Help,' ') <> NVL(e.Help,' ') OR NVL(f.Placeholder,' ') <> NVL(e.Placeholder,' ')))";
+" 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,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand Down Expand Up @@ -378,7 +378,7 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(et.Description,' ') OR NVL(trl.Help,' ') <> NVL(et.Help,' ') OR NVL(trl.Placeholder,' ') <> NVL(et.Placeholder,' ')))";
+" 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,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand Down Expand Up @@ -406,7 +406,7 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(et.Description,' ') OR NVL(trl.Help,' ') <> NVL(et.Help,' ') OR NVL(trl.Placeholder,' ') <> NVL(et.Placeholder,' ')))";
+" 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,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -423,7 +423,7 @@ protected String doIt() throws Exception
+" 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 NVL(w.Description,' ') <> NVL(n.Description,' ') OR NVL(w.Help,' ') <> NVL("
+" AND (w.Name <> n.Name OR COALESCE(w.Description,' ') <> COALESCE(n.Description,' ') OR COALESCE(w.Help,' ') <> COALESCE("
+ (DB.isOracle() ? "dbms_lob.substr(n.Help, 4000, 1 )" : "n.Help")
+",' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
Expand All @@ -445,9 +445,9 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(t.Description,' ') OR NVL("
+" AND (trl.Name <> t.Name OR COALESCE(trl.Description,' ') <> COALESCE(t.Description,' ') OR COALESCE("
+ (DB.isOracle() ? "dbms_lob.substr(trl.Help, 4000, 1 )" : "trl.Help")
+",' ') <> NVL(t.Help,' ')))";
+",' ') <> COALESCE(t.Help,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -461,7 +461,7 @@ protected String doIt() throws Exception
+" 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 NVL(f.Description,' ') <> NVL(n.Description,' ') OR NVL(f.Help,' ') <> NVL("
+" AND (f.Name <> n.Name OR COALESCE(f.Description,' ') <> COALESCE(n.Description,' ') OR COALESCE(f.Help,' ') <> COALESCE("
+ (DB.isOracle() ? "dbms_lob.substr(n.Help, 4000, 1 )" : "n.Help")
+",' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
Expand All @@ -478,9 +478,9 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(t.Description,' ') OR NVL("
+" AND (trl.Name <> t.Name OR COALESCE(trl.Description,' ') <> COALESCE(t.Description,' ') OR COALESCE("
+ (DB.isOracle() ? "dbms_lob.substr(trl.Help, 4000, 1 )" : "trl.Help")
+",' ') <> NVL(t.Help,' ')))";
+",' ') <> COALESCE(t.Help,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand All @@ -494,7 +494,7 @@ protected String doIt() throws Exception
+" 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 NVL(f.Description,' ') <> NVL(n.Description,' ') OR NVL(f.Help,' ') <> NVL("
+" AND (f.Name <> n.Name OR COALESCE(f.Description,' ') <> COALESCE(n.Description,' ') OR COALESCE(f.Help,' ') <> COALESCE("
+ (DB.isOracle() ? "dbms_lob.substr(n.Help, 4000, 1 )" : "n.Help")
+",' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
Expand All @@ -511,9 +511,9 @@ protected String doIt() throws Exception
+" 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 NVL(trl.Description,' ') <> NVL(t.Description,' ') OR NVL("
+" AND (trl.Name <> t.Name OR COALESCE(trl.Description,' ') <> COALESCE(t.Description,' ') OR COALESCE("
+ (DB.isOracle() ? "dbms_lob.substr(trl.Help, 4000, 1 )" : "trl.Help")
+",' ') <> NVL(t.Help,' ')))";
+",' ') <> COALESCE(t.Help,' ')))";
no = DB.executeUpdate(sql, false, get_TrxName());
if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no);
trx.commit(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ protected String doIt () throws Exception
//
if (p_Search_InOut_ID != 0){
StringBuilder msgtrx = new StringBuilder(
"SELECT NVL(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ")
"SELECT COALESCE(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);
insertTrx(msgtrx.toString());
}
else if (p_Search_Order_ID != 0){
StringBuilder msgtrx = new StringBuilder(
"SELECT NVL(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ")
"SELECT COALESCE(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)")
Expand All @@ -85,7 +85,7 @@ else if (p_Search_Order_ID != 0){
}
else if (p_Search_Invoice_ID != 0){
StringBuilder msgtrx = new StringBuilder(
"SELECT NVL(ma.M_AttributeSetInstance_ID,iol.M_AttributeSetInstance_ID) ")
"SELECT COALESCE(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) ")
Expand Down
2 changes: 1 addition & 1 deletion org.adempiere.base/src/org/compiere/model/GridTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ public String getTrxInfo()
Object[] arguments = new Object[3];
boolean filled = false;
//
String sql = "SELECT COUNT(*), NVL(SUM(LineNetAmt),0), NVL(SUM(LineTotalAmt),0) "
String sql = "SELECT COUNT(*), COALESCE(SUM(LineNetAmt),0), COALESCE(SUM(LineTotalAmt),0) "
+ "FROM C_InvoiceBatchLine "
+ "WHERE C_InvoiceBatch_ID=? AND IsActive='Y'";
//
Expand Down
2 changes: 1 addition & 1 deletion org.adempiere.base/src/org/compiere/model/MBOMProduct.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ && getM_BOMAlternative_ID() == 0)
// Set Line Number
if (getLine() == 0)
{
String sql = "SELECT NVL(MAX(Line),0)+10 FROM M_BOMProduct WHERE M_BOM_ID=?";
String sql = "SELECT COALESCE(MAX(Line),0)+10 FROM M_BOMProduct WHERE M_BOM_ID=?";
int ii = DB.getSQLValue (get_TrxName(), sql, getM_BOM_ID());
setLine (ii);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void updateEntry()
{
// 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=NVL((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)")
.append("SET Amt=COALESCE((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(*)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected boolean afterSave (boolean newRecord, boolean success)
if (success)
{
StringBuilder sql = new StringBuilder("UPDATE C_InvoiceBatch h ")
.append("SET DocumentAmt = NVL((SELECT SUM(LineTotalAmt) FROM C_InvoiceBatchLine l ")
.append("SET DocumentAmt = COALESCE((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());
Expand Down
2 changes: 1 addition & 1 deletion org.adempiere.base/src/org/compiere/model/MLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private void setAD_Language_ID()
int AD_Language_ID = getAD_Language_ID();
if (AD_Language_ID == 0)
{
String sql = "SELECT NVL(MAX(AD_Language_ID), 999999) FROM AD_Language WHERE AD_Language_ID > 1000";
String sql = "SELECT COALESCE(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);
}
Expand Down
Loading

0 comments on commit 2c639f7

Please sign in to comment.