Bitwise operators for Oracle

Posts   
 
    
ww
User
Posts: 83
Joined: 01-Oct-2004
# Posted on: 14-Jun-2020 19:42:43   

I'm using version 4.1 for this project.

The RTF documentation for all version I've seen says that "BitwiseOr, BitwiseAnd and BitwiseXor. The bitwise operations are for SqlServer or PostgreSql only." But I saw a forum post indicating that they're supported for Oracle as of v3.

When I use ExOp.BitwiseAnd for an Oracle project, the generated query uses SQL Server syntax :


where (x&y)=z

instead of Oracle syntax:


where bitand(x&y)=z

I haven't tested in a later version but don't see anything about this in any release notes.

So, if bitwise operators are supposed to be supported for Oracle, they don't appear to be working.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Jun-2020 07:32:08   

ww wrote:

The RTF documentation for all version I've seen says that "BitwiseOr, BitwiseAnd and BitwiseXor. The bitwise operations are for SqlServer or PostgreSql only." But I saw a forum post indicating that they're supported for Oracle as of v3.

Hi ww. Yes, that's what is stated in the documentation and that's what is supported. BITAND(n1,n2) and other oracle's bitwise functions are considered functions not operators.

The thread you are referring to (I think is this) is a very old thread (2005) referring to a 3rd party contribution about a Bitwise predicate when the LLBLGen Framework didn't support Bitwise operators. Anyway the framework supports Bitwise operators, the BIT??? functions are functions.

To be able to use BITAND and others in your fields or predicates, you should use a function call (ref...).

I hope that helps simple_smile

David Elizondo | LLBLGen Support Team
ww
User
Posts: 83
Joined: 01-Oct-2004
# Posted on: 16-Jun-2020 15:02:08   

That is the forum thread I was referring to. I wasn't thinking about the distinction between operator and function so I was expecting that when I used the ExOp filter LLBLGEN would construct a query using BITAND. Instead it creates the query using the (unsupported) "&" operator, and the query fails with Oracle error ORA-00920: invalid relational operator.

Thanks for the pointer to calling functions instead--I hadn't thought of that somehow. (Your link to an example of BITAND doesn't go anywhere but the reference guide is enough.)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 17-Jun-2020 08:56:52   

The Bitand link was to a thread in 'helpdesk', hence it didn't go anywhere. the example for completeness:

IExpression myExp = new DbFunctionCall( "bitand", new object[] { AddressTypeFields.IdModuleType, 2} );
IEntityField myField = MyEntityFields.Field1.SetExpression(myExp);
PredicateExpression myFilter = new PredicateExpression(myField > 0)

The "&" Operator doesn't have a function mapping in the DQE, however your description shows it should have. We'll look into adding that in a future version.

Frans Bouma | Lead developer LLBLGen Pro
ww
User
Posts: 83
Joined: 01-Oct-2004
# Posted on: 17-Jun-2020 15:22:08   

Thank you.