Solved

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

Posted on 2008-10-02
2
552 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

634 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