Bitwise operators in SQLs/4GLs
Posted in 2004
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Internationalization & Character Sets
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? -- Scott Burns Mirrabooka Systems Tel +61 7 3857 7899 Fax +61 7 3857 1368
You could compile in a C function: int bitwise_and(int nargs) { int arg[2]; popint(&arg[2]); popint(&arg[1]); retint(arg[1] & arg[2]); return(1); } Test 4GL module: MAIN DEFINE x INTEGER LET x = bitwise_and(ARG_VAL(1),ARG_VAL(2)) DISPLAY x END MAIN Compile command: c4gl -o bitwise.4ge bitwise.4gl bitwise_and.c -- Regards, Doug Lawry www.douglawry.webhop.org "Scott Burns" <scott@mirrabooka.com> wrote: > 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? > > -- > Scott Burns > Mirrabooka Systems > > Tel +61 7 3857 7899 > Fax +61 7 3857 1368
Scott Burns schrieb: > 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? > Hi Scott, search Google Newsgroups for my posting from around Feb. 2003, where I posted some stored procedures which will do the job. Regards Roland -- Roland Wintgen (Systemadministrator) EVG Elektro-Vertriebs-Gesellschaft Martens GmbH & Co KG Trompeterallee 244-246, D-41189 Moenchengladbach Tel. +49 21 66 / 55 08 23, Fax 0 21 66 / 55 08 90 www.evg.de rw@evg.de
Related threads
- Compiling dbschema
- [GERMAN] 4GL-Trainingsanbieter gesucht
- RE: Performance Monitoring/Tuning
- IF and SELECT statement newbie question