IDEMPIERE-4254 get oracle error ORA-01795 when has more than 1000 org (#109)
This commit is contained in:
parent
940885c38c
commit
10771a7408
|
@ -1137,17 +1137,22 @@ public final class MRole extends X_AD_Role
|
|||
//
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<String> it = set.iterator();
|
||||
boolean oneOnly = true;
|
||||
final int MAX_ORACLE_ELEMENTS_IN_ORACLE = 1000;
|
||||
int idx = 0;
|
||||
while (it.hasNext())
|
||||
{
|
||||
idx++;
|
||||
if (sb.length() > 0)
|
||||
{
|
||||
sb.append(",");
|
||||
oneOnly = false;
|
||||
if (DB.isOracle() && (idx-1) % MAX_ORACLE_ELEMENTS_IN_ORACLE == 0) { // prevent ORA-01795
|
||||
sb.append(") OR AD_Org_ID IN (");
|
||||
} else {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.append(it.next());
|
||||
}
|
||||
if (oneOnly)
|
||||
if (sb.indexOf(",") < 0) // only one org
|
||||
{
|
||||
if (sb.length() > 0)
|
||||
return "AD_Org_ID=" + sb.toString();
|
||||
|
@ -1157,8 +1162,8 @@ public final class MRole extends X_AD_Role
|
|||
return "AD_Org_ID=-1"; // No Access Record
|
||||
}
|
||||
}
|
||||
return "AD_Org_ID IN(" + sb.toString() + ")";
|
||||
} // getOrgWhereValue
|
||||
return "(AD_Org_ID IN (" + sb.toString() + "))";
|
||||
} // getOrgWhere
|
||||
|
||||
/**
|
||||
* Access to Org
|
||||
|
@ -1997,9 +2002,10 @@ public final class MRole extends X_AD_Role
|
|||
if (!isAccessAllOrgs())
|
||||
{
|
||||
retSQL.append(" AND ");
|
||||
String orgWhere = getOrgWhere(rw);
|
||||
if (fullyQualified)
|
||||
retSQL.append(tableName).append(".");
|
||||
retSQL.append(getOrgWhere(rw));
|
||||
orgWhere = orgWhere.replaceAll("AD_Org_ID", tableName + ".AD_Org_ID");
|
||||
retSQL.append(orgWhere);
|
||||
}
|
||||
} else {
|
||||
retSQL.append("1=1");
|
||||
|
|
|
@ -428,7 +428,8 @@ public class InvoicePrint extends SvrProcess
|
|||
}
|
||||
String orgWhere = MRole.getDefault(getCtx(), false).getOrgWhere(MRole.SQL_RO);
|
||||
if (!Util.isEmpty(orgWhere, true)) {
|
||||
sql.append(" AND i.");
|
||||
orgWhere = orgWhere.replaceAll("AD_Org_ID", "i.AD_Org_ID");
|
||||
sql.append(" AND ");
|
||||
sql.append(orgWhere);
|
||||
}
|
||||
sql.append(" ORDER BY i.C_Invoice_ID, pf.AD_Org_ID DESC"); // more than 1 PF record
|
||||
|
|
Loading…
Reference in New Issue