Nothing new, just to reiterate the basics.
Say, we need to add a computed column as a result of OR function over two other columns of Boolean type: wblPPOFirmDisableForSalesLine and wblPPOFirmDisableForTransferLine.
Create a new field wblPPOFirmDisable as Enum Computed field
and point it to the following method.
The whole point is to create a string with an SQL statement as a result in static method. There are a lot of standard functions in SysComputedColumn class aiming to help with syntax.
As you can see in this example it is not enough to get a logical comparison result at the first sRet assigning. The latter must be converted explicitly to an SQL string as it goes at the second step.
Finally we get the following string as a part of the whole SQL statement.
CASE WHEN (T1.WBLPPOFIRMDISABLEFORSALESLINE = 1) OR (T1.WBLPPOFIRMDISABLEFORTRANSFERLINE = 1) THEN 1 ELSE 0 END
Say, we need to add a computed column as a result of OR function over two other columns of Boolean type: wblPPOFirmDisableForSalesLine and wblPPOFirmDisableForTransferLine.
Create a new field wblPPOFirmDisable as Enum Computed field
and point it to the following method.
private static server str wblPPOFirmDisable(int _tableNum) { DictView ctView = new DictView(tableNum(wblPeggedRefTransOnHoldUnionView)); str sTransType1 = SysComputedColumn::comparisonField(identifierStr(wblPeggedRefTransOnHoldUnionView), identifierStr(wblSalesTableOnHoldView), fieldStr(wblSalesTableOnHoldView, wblPPOFirmDisableForSalesLine)); str sTransType2 = SysComputedColumn::comparisonField(identifierStr(wblPeggedRefTransOnHoldUnionView), identifierStr(wblSalesTableOnHoldView), fieldStr(wblSalesTableOnHoldView, wblPPOFirmDisableForTransferLine)); str sRet = ''; sRet = SysComputedColumn::or2 ( SysComputedColumn::equalExpression(sTransType1, SysComputedColumn::returnLiteral(NoYes::Yes)), SysComputedColumn::equalExpression(sTransType2, SysComputedColumn::returnLiteral(NoYes::Yes)) ); sRet = SysComputedColumn::if(sRet, SysComputedColumn::returnLiteral(NoYes::Yes), SysComputedColumn::returnLiteral(NoYes::No)); return sRet; }
The whole point is to create a string with an SQL statement as a result in static method. There are a lot of standard functions in SysComputedColumn class aiming to help with syntax.
As you can see in this example it is not enough to get a logical comparison result at the first sRet assigning. The latter must be converted explicitly to an SQL string as it goes at the second step.
Finally we get the following string as a part of the whole SQL statement.
CASE WHEN (T1.WBLPPOFIRMDISABLEFORSALESLINE = 1) OR (T1.WBLPPOFIRMDISABLEFORTRANSFERLINE = 1) THEN 1 ELSE 0 END
No comments:
Post a Comment