Solved

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

Posted on 2008-10-02
2
526 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

840 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