Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-02
2
Medium Priority
?
560 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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

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…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 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