* [ 1638046 ] DB-error shema "j" does not exist when creating GL journal
This commit is contained in:
parent
a18373e5a9
commit
5278ced530
|
@ -866,7 +866,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
}
|
}
|
||||||
} else if (retValue.indexOf("ROWNUM=1") > 1) {
|
} else if (retValue.indexOf("ROWNUM=1") > 1) {
|
||||||
int rownum = retValue.indexOf("ROWNUM=1");
|
int rownum = retValue.indexOf("ROWNUM=1");
|
||||||
System.out.println("retValue" + retValue);
|
//System.out.println("retValue" + retValue);
|
||||||
if (retValue.substring(0, rownum).contains("WHERE")) {
|
if (retValue.substring(0, rownum).contains("WHERE")) {
|
||||||
retValue = Util.replace(retValue, "ROWNUM=1 ", " LIMIT 1");
|
retValue = Util.replace(retValue, "ROWNUM=1 ", " LIMIT 1");
|
||||||
return convert + retValue;
|
return convert + retValue;
|
||||||
|
@ -959,7 +959,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
// sqlStatement = sqlStatement.replaceFirst(",'DY'", "");
|
// sqlStatement = sqlStatement.replaceFirst(",'DY'", "");
|
||||||
return sqlStatement;
|
return sqlStatement;
|
||||||
}
|
}
|
||||||
System.out.println("SQL=" + sqlStatement);
|
//System.out.println("SQL=" + sqlStatement);
|
||||||
return sqlStatement;
|
return sqlStatement;
|
||||||
|
|
||||||
// end vpj-cd e-evolution 09/02/2005 PostgreSQL
|
// end vpj-cd e-evolution 09/02/2005 PostgreSQL
|
||||||
|
@ -1231,7 +1231,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
if (f < 0) {
|
if (f < 0) {
|
||||||
updateField = updateFields;
|
updateField = updateFields;
|
||||||
joinField = joinFields.trim();
|
joinField = joinFields.trim();
|
||||||
if (joinField.indexOf(".") < 0) {
|
if (joinField.indexOf(".") < 0 && isIdentifier(joinField)) {
|
||||||
joinField = joinAlias + "." + joinField;
|
joinField = joinAlias + "." + joinField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,8 +1279,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
// fieldsjoin.indexOf(',');
|
// fieldsjoin.indexOf(',');
|
||||||
|
|
||||||
joinField = joinFields.substring(0, fj).trim();
|
joinField = joinFields.substring(0, fj).trim();
|
||||||
if (joinField.indexOf(".") < 0 != joinField
|
if (joinField.indexOf(".") < 0 && isIdentifier(joinField)) {
|
||||||
.equals("SysDate")) {
|
|
||||||
joinField = joinAlias + "." + joinField;
|
joinField = joinAlias + "." + joinField;
|
||||||
}
|
}
|
||||||
Update.append(updateField.trim());
|
Update.append(updateField.trim());
|
||||||
|
@ -1464,9 +1463,14 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
*/
|
*/
|
||||||
private boolean isIdentifier(String token)
|
private boolean isIdentifier(String token)
|
||||||
{
|
{
|
||||||
if (isOperator(token))
|
int size = token.length();
|
||||||
return false;
|
for (int i = 0; i < size; i++)
|
||||||
else if (token.startsWith("'") && token.startsWith("'"))
|
{
|
||||||
|
char c = token.charAt(i);
|
||||||
|
if (isOperator(c))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (token.startsWith("'") && token.endsWith("'"))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -181,6 +181,20 @@ public final class Convert_PostgreSQLTest {
|
||||||
r = convert.convert(sql);
|
r = convert.convert(sql);
|
||||||
verify(sql, r, "UPDATE T_InventoryValue SET PricePO = (SELECT currencyConvert (po.PriceList,po.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, po.AD_Client_ID,po.AD_Org_ID) FROM M_Product_PO po WHERE po.M_Product_ID=T_InventoryValue.M_Product_ID AND po.IsCurrentVendor='Y' LIMIT 1 ), PriceList = (SELECT currencyConvert(pp.PriceList,pl.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID) FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp WHERE pp.M_Product_ID=T_InventoryValue.M_Product_ID AND pp.M_PriceList_Version_ID=T_InventoryValue.M_PriceList_Version_ID AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID AND plv.M_PriceList_ID=pl.M_PriceList_ID), PriceStd = (SELECT currencyConvert(pp.PriceStd,pl.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID) FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp WHERE pp.M_Product_ID=T_InventoryValue.M_Product_ID AND pp.M_PriceList_Version_ID=T_InventoryValue.M_PriceList_Version_ID AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID AND plv.M_PriceList_ID=pl.M_PriceList_ID), PriceLimit = (SELECT currencyConvert(pp.PriceLimit,pl.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID) FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp WHERE pp.M_Product_ID=T_InventoryValue.M_Product_ID AND pp.M_PriceList_Version_ID=T_InventoryValue.M_PriceList_Version_ID AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID AND plv.M_PriceList_ID=pl.M_PriceList_ID)");
|
verify(sql, r, "UPDATE T_InventoryValue SET PricePO = (SELECT currencyConvert (po.PriceList,po.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, po.AD_Client_ID,po.AD_Org_ID) FROM M_Product_PO po WHERE po.M_Product_ID=T_InventoryValue.M_Product_ID AND po.IsCurrentVendor='Y' LIMIT 1 ), PriceList = (SELECT currencyConvert(pp.PriceList,pl.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID) FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp WHERE pp.M_Product_ID=T_InventoryValue.M_Product_ID AND pp.M_PriceList_Version_ID=T_InventoryValue.M_PriceList_Version_ID AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID AND plv.M_PriceList_ID=pl.M_PriceList_ID), PriceStd = (SELECT currencyConvert(pp.PriceStd,pl.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID) FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp WHERE pp.M_Product_ID=T_InventoryValue.M_Product_ID AND pp.M_PriceList_Version_ID=T_InventoryValue.M_PriceList_Version_ID AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID AND plv.M_PriceList_ID=pl.M_PriceList_ID), PriceLimit = (SELECT currencyConvert(pp.PriceLimit,pl.C_Currency_ID,T_InventoryValue.C_Currency_ID,T_InventoryValue.DateValue,null, pl.AD_Client_ID,pl.AD_Org_ID) FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp WHERE pp.M_Product_ID=T_InventoryValue.M_Product_ID AND pp.M_PriceList_Version_ID=T_InventoryValue.M_PriceList_Version_ID AND pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID AND plv.M_PriceList_ID=pl.M_PriceList_ID)");
|
||||||
|
|
||||||
|
//bug [ 1638046 ]
|
||||||
|
sql = "UPDATE GL_JournalBatch jb"
|
||||||
|
+ " SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(TotalDr),0), COALESCE(SUM(TotalCr),0)"
|
||||||
|
+ " FROM GL_Journal j WHERE j.IsActive='Y' AND jb.GL_JournalBatch_ID=j.GL_JournalBatch_ID) "
|
||||||
|
+ "WHERE GL_JournalBatch_ID=0";
|
||||||
|
r = convert.convert(sql);
|
||||||
|
sqe = "UPDATE GL_JournalBatch SET TotalDr="
|
||||||
|
+ "( SELECT COALESCE(SUM(TotalDr),0) "
|
||||||
|
+ "FROM GL_Journal j WHERE j.IsActive='Y' AND "
|
||||||
|
+ "GL_JournalBatch.GL_JournalBatch_ID=j.GL_JournalBatch_ID ) ,"
|
||||||
|
+ "TotalCr=( SELECT COALESCE(SUM(TotalCr),0) FROM GL_Journal j "
|
||||||
|
+ "WHERE j.IsActive='Y' AND GL_JournalBatch.GL_JournalBatch_ID=j.GL_JournalBatch_ID ) "
|
||||||
|
+ " WHERE GL_JournalBatch_ID=0";
|
||||||
|
verify(sql, r, sqe);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verify(String original, String[] converted, String expected) {
|
private void verify(String original, String[] converted, String expected) {
|
||||||
|
|
Loading…
Reference in New Issue