Solved

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

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…

734 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