Solved

SQL statement with binary notation value in a Field - HOW?

Posted on 2008-10-02
2
484 Views
Last Modified: 2013-12-09
Hi Experts,
I have a database application in Delphi 6 with Firebird 1.5 backend. This is the required behavior.
Whenever an administrator creates a record, he will assign the clients (All or 1 to 4) eligible to view. I'm saving the selected value as integer using binary notation. Eg  
0 - all can view (0000)
1 - Only Client 1 can view (0001)
2 - Only Client 2 can view (0010)
3 - 1 & 2 can view (0011)
4 - Only Client 3 can view (0100)
5 - 1 & 3 can view  (0101)

Now on the client side, how can I select those records viewable by a particular client?
Am I doing something complex? Or Should I change the way I store the value? I can change the design if there are better suggestions.

Regards
PCS

0
Comment
Question by:pcssecure
2 Comments
 
LVL 19

Accepted Solution

by:
NickUpson earned 500 total points
ID: 22626141
you want to use the bin_and and bin_or udf functions that come with 1.5 but are not installed by default, there are scripts in the UDF directory of the firebird instaliation. you can then do "select .... from .... where .... and bin_and(client_id, binary_view)

if datavolumes are large this may be slow

0
 

Author Closing Comment

by:pcssecure
ID: 31502420
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now