Re: Bitwise operators in SQLs/4GLs
Posted in 2004
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Internationalization & Character Sets
Scott Burns said: > Hi, > just wanted to confirm my impression that 4gl won't let you use > logical ands in select on bit fields under SE. > > What we want to do is select ... where amendFlag & 0x6, that is, > when the second and third bits of amendFlag are set. > > I suspect we are going to be reduced to selecting all then manually > running through each to find the one we want. > > Are there easier/better ways? Why on earth are you using bitwise operators in a 4GL/RDBMS environment? The major point of that environment for me has always been ease of development and maintenance, bitwise operators are far to complicated. -- Bye now, Obnoxio "C'est pas parce qu'on n'a rien ' dire qu'il faut fermer sa gueule" - Coluche "I'm trying to see things your way, but I can't get my head up my ass" - JCH "Ogni uomo mi guarda come se fossi una testa di cazzo" - Marco http://www.catb.org/~esr/faqs/smart-questions.html sending to informix-list
Obnoxio The Clown wrote: > > >Why on earth are you using bitwise operators in a 4GL/RDBMS environment? >The major point of that environment for me has always been ease of >development and maintenance, bitwise operators are far to complicated. > > > I agree. For preference, I'd rewrite it to use seperate fields for each flag. I mean, it won't even display properly in a perform screen, and the hoops we need to jump through for an sql is rediculous. After an hour or so I came up with MOD( ROUND( ( ( amdflag / 4 ) - 0.5 ), 0 ), 2 ) = 1 AND MOD( ROUND( ( ( amdflag / 2 ) - 0.5 ), 0 ), 2 ) = 1 It's not the sort of code I'm going to tell the kids about. Unfortunately, it has been declared that This Is The Way, which means that this is the way we have to do it. Fortunately, it's not me in particular that now has to do the work, so when programmers through the years look back through source control my name will be nowhere near this abomination. -- Scott Burns Mirrabooka Systems Tel +61 7 3857 7899 Fax +61 7 3857 1368