Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 849D7475873 for ; Sun, 14 Jul 2002 00:28:51 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 223CD382152; Sun, 14 Jul 2002 00:27:56 -0400 (EDT) From: Ahti Legonkov X-Newsgroups: comp.databases.postgresql.sql Subject: Re: sql question: Date: Sun, 14 Jul 2002 05:38:45 +0300 Lines: 35 Message-ID: <3D30E435.4070208@127.0.0.1> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@kadri.ut.ee User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en To: pgsql-sql@postgresql.org X-Archive-Number: 200207/213 X-Sequence-Number: 8591 Chris Aiello wrote: > hi all: > > I'm trying to figure out SQL to do the following: > I have an application that tracks SQL that is being sent to the database, > and one of it's features is the ability to identify whether a query is an > insert, update, delete, select, select with all rows returned, the query is > the first in a user session....and many other criteria. Because of the > nature of SQL, i.e. many of the above could be true, the deisgners made each > flag a 'bit'. So an example is: > 4 is a select > 8 is insert > 16 is update > 32 is first query in session > 64 is delete > 128 is a cancelled query > 256 is database cancelled query > > > > Now the SQL that I have to find is 'which of these records is a delete?' > The values could be 64, 96, 416, 445, 320 and many others. All in all > there are probably 20 possible values and the permutations are to lengthy to > put in a 'like', so I need some kind of algorithm. Does anyone have any > ideas? The algorithm is as simple as that: if (value & 64 == 64) { // it is a delete } -- Ahti Legonkov