Wrong SQL buld in business service Table I/O when using OR in WHERE clause

cscdans

Well Known Member
Hi List,
when I wrote a BSSV with a select on a table, I had a stange behaviour and found out that brackets are set wrong by JDE when using an OR in a where clause. To simplyfy everything, I wrote an additional Test BSSV with the same behaviour. For this example it just shall do
SELECT F0005.KY, F0005.DL01, F0005.DL02
FROM F0005
WHERE F0005.SY=sysvar1 AND F0005.RT=rtvar1 OR F0005.SY=sysvar2 AND F0005.RT=rtvar2
ORDER BY F0005.SY ASC, F0005.RT ASC, F0005.KY ASC

I used the JDE expression builder and it generated:
BSSVDBWhereField[] whereFields =
{new BSSVDBWhereField(null, new BSSVDBField("F0005.SY"), IDBService.EQUALS, internalVO.getQueryWhereFields().getF0005_SY1()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F0005.RT"), IDBService.EQUALS, internalVO.getQueryWhereFields().getF0005_RT1()),
new BSSVDBWhereField(IDBService.OR, new BSSVDBField("F0005.SY"), IDBService.EQUALS, internalVO.getQueryWhereFields().getF0005_SY2()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F0005.RT"), IDBService.EQUALS, internalVO.getQueryWhereFields().getF0005_RT2())};

what is ok (looks very similar to c-selection struct, eh? ;-) )

but the log reports:
14 Jul 2009 17:21:33,061 [APP ] - [JDBJ] SELECT DRKY,DRDL01,DRDL02,DRSY,DRRT FROM TESTCTL.F0005 WHERE (((((DRSY = ? ) AND DRRT = ? ) OR DRSY = ? ) AND DRRT = ? )) ORDER BY DRSY ASC , DRRT ASC , DRKY ASC
14 Jul 2009 17:21:33,061 [APP ] - [JDBJ] SQL statement parameter marker values are :
14 Jul 2009 17:21:33,061 [APP ] - [JDBJ] Param1 : 01_Types.VARCHAR,
14 Jul 2009 17:21:33,061 [APP ] - [JDBJ] Param2 : 01_Types.VARCHAR,
14 Jul 2009 17:21:33,061 [APP ] - [JDBJ] Param3 : H95_Types.VARCHAR,
14 Jul 2009 17:21:33,061 [APP ] - [JDBJ] Param4 : AI_Types.VARCHAR,

So result fits to the logged sql:
SELECT DRKY,DRDL01,DRDL02,DRSY,DRRT FROM TESTCTL.F0005 WHERE (((((DRSY = '01' ) AND DRRT = '01' ) OR DRSY = 'H95' ) AND DRRT = 'AI' )) ORDER BY DRSY ASC , DRRT ASC , DRKY ASC
when you resolve the brackets the result will be
SELECT DRKY,DRDL01,DRDL02,DRSY,DRRT FROM TESTCTL.F0005 WHERE DRSY = '01' AND DRRT = '01' AND DRRT = 'AI' OR DRSY = 'H95' AND DRRT = 'AI' ORDER BY DRSY ASC , DRRT ASC , DRKY ASC

WHAT IS NOT EQUAL TO THE STATEMENT ENTERED IN THE JAVACODE WHICH EXSPECTED RESULT SHOULD BE:

SELECT DRKY,DRDL01,DRDL02,DRSY,DRRT FROM TESTCTL.F0005 WHERE DRSY = '01' AND DRRT = '01' OR DRSY = 'H95' AND DRRT = 'AI' ORDER BY DRSY ASC , DRRT ASC , DRKY ASC .

I zipped the BSSV, so you shall be able to test it yourself an you able to llok at the code.
I guess it is an error in the java library of oracle in oracle.e1.bssvfoundation.services

But perhaps someone has a tip or perhaps it is my fault and I do not see it.

Thank you and best regards,
Carsten

We use 8.12 TOOLS 8.98 Update 1, iSeriies with DB2/400. Webserver Oracle unbreakable linux 5 with Oracle Application Server 10.1.3.3.0
JDEveloper Version 10.1.3.4.0
 

Attachments

  • 148307-JP57TEST.zip
    15.8 KB · Views: 164
Hello,
for all having similar problems with selection in BSSV:
Oracle development is working on a bugfix, nut it can take some days (up to some month).
Best regards,
Carsten
 
Hello,
here is the SAR No: SAR 8941735
But it is still not fixed :-(
Best regards,
Carsten
 
I know this post is very old but Is there anyone who can help on this. I am stuck in the same situation (it is 2023 so I think the issue must have been resolved by now). Please help.

In bssv I have a requirement to get data from a business view (based on 2 table F4201, and F4211), below is the query I am using:

BSSVDBWhereField[] whereFields = {
new BSSVDBWhereField(null, new BSSVDBField("F4201.KCOO"), IDBService.EQUALS, internalVO.getF4201_KCOO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.DCTO"), IDBService.EQUALS,
internalVO.getF4201_DCTO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.SHAN"), IDBService.EQUALS,
internalVO.getF4201_SHAN()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.NXTR"), IDBService.GREATER_THAN, "580"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.LTTR"), IDBService.NOT_EQUAL, "980"),

new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.SOQS"), IDBService.GREATER_THAN, 0),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.TRDJ"), IDBService.GREATER_THAN_OR_EQUAL_TO,
internalVO.getDate()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.URAB"), IDBService.EQUALS, 0),
new BSSVDBWhereField(IDBService.OR, new BSSVDBField("F4201.KCOO"), IDBService.EQUALS, internalVO.getF4201_KCOO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.DCTO"), IDBService.EQUALS,
internalVO.getF4201_DCTO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.SHAN"), IDBService.EQUALS,
internalVO.getF4201_SHAN()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.NXTR"), IDBService.GREATER_THAN, "580"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.LTTR"), IDBService.NOT_EQUAL, "980"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.URAB"), IDBService.EQUALS, 1),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.SOQS"), IDBService.GREATER_THAN, 0),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.TRDJ"), IDBService.GREATER_THAN_OR_EQUAL_TO,
internalVO.getDate()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.OCTO"), IDBService.EQUALS, "S7"),

};




but using this, I am getting output only from 2nd half statements (OR condition), above ones are not selected. However, if I remove the statements 2nd half (after OR is added), I get the output from 1st half.
 
I know this post is very old but Is there anyone who can help on this. I am stuck in the same situation (it is 2023 so I think the issue must have been resolved by now). Please help.

In bssv I have a requirement to get data from a business view (based on 2 table F4201, and F4211), below is the query I am using:

BSSVDBWhereField[] whereFields = {
new BSSVDBWhereField(null, new BSSVDBField("F4201.KCOO"), IDBService.EQUALS, internalVO.getF4201_KCOO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.DCTO"), IDBService.EQUALS,
internalVO.getF4201_DCTO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.SHAN"), IDBService.EQUALS,
internalVO.getF4201_SHAN()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.NXTR"), IDBService.GREATER_THAN, "580"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.LTTR"), IDBService.NOT_EQUAL, "980"),

new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.SOQS"), IDBService.GREATER_THAN, 0),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.TRDJ"), IDBService.GREATER_THAN_OR_EQUAL_TO,
internalVO.getDate()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.URAB"), IDBService.EQUALS, 0),
new BSSVDBWhereField(IDBService.OR, new BSSVDBField("F4201.KCOO"), IDBService.EQUALS, internalVO.getF4201_KCOO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.DCTO"), IDBService.EQUALS,
internalVO.getF4201_DCTO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.SHAN"), IDBService.EQUALS,
internalVO.getF4201_SHAN()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.NXTR"), IDBService.GREATER_THAN, "580"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.LTTR"), IDBService.NOT_EQUAL, "980"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.URAB"), IDBService.EQUALS, 1),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.SOQS"), IDBService.GREATER_THAN, 0),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.TRDJ"), IDBService.GREATER_THAN_OR_EQUAL_TO,
internalVO.getDate()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.OCTO"), IDBService.EQUALS, "S7"),

};




but using this, I am getting output only from 2nd half statements (OR condition), above ones are not selected. However, if I remove the statements 2nd half (after OR is added), I get the output from 1st half.

Hi, all!

I hope you all have solved that problem some way.

I had the same issue and didn't find the answer here, so I solved (or workarounded) with something like this (I used your own code as a sample):

BSSVDBWhereField[] whereFields = {
new BSSVDBWhereField("("),
new BSSVDBWhereField(null, new BSSVDBField("F4201.KCOO"), IDBService.EQUALS, internalVO.getF4201_KCOO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.DCTO"), IDBService.EQUALS,internalVO.getF4201_DCTO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.SHAN"), IDBService.EQUALS,internalVO.getF4201_SHAN()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.NXTR"), IDBService.GREATER_THAN, "580"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.LTTR"), IDBService.NOT_EQUAL, "980"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.SOQS"), IDBService.GREATER_THAN, 0),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.TRDJ"), IDBService.GREATER_THAN_OR_EQUAL_TO,internalVO.getDate()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.URAB"), IDBService.EQUALS, 0),
new BSSVDBWhereField(")"),
new BSSVDBWhereField("("),

new BSSVDBWhereField(IDBService.OR, new BSSVDBField("F4201.KCOO"), IDBService.EQUALS, internalVO.getF4201_KCOO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.DCTO"), IDBService.EQUALS,internalVO.getF4201_DCTO()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.SHAN"), IDBService.EQUALS,internalVO.getF4201_SHAN()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.NXTR"), IDBService.GREATER_THAN, "580"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.LTTR"), IDBService.NOT_EQUAL, "980"),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.URAB"), IDBService.EQUALS, 1),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.SOQS"), IDBService.GREATER_THAN, 0),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4201.TRDJ"), IDBService.GREATER_THAN_OR_EQUAL_TO,internalVO.getDate()),
new BSSVDBWhereField(IDBService.AND, new BSSVDBField("F4211.OCTO"), IDBService.EQUALS, "S7"),
new BSSVDBWhereField(")")
};
 

Similar threads

Back
Top