Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Bitwise manipulation for an update statement.

Re: Bitwise manipulation for an update statement.

From: KurtisK <KJKYLE_at_COOLBLUENOSPAM.COM>
Date: Wed, 1 Dec 2004 17:20:37 -0500
Message-ID: <-sednSyM74Aq3jPcRVn-pg@telcove.net>


update your_table
set StatusA = StatusA + case bitand(StatusA, 1) when 0 then 1 else 0 end set StatusB = StatusB + case bitand(StatusB, 1) when 0 then 1 else 0 end where id = your_id

Add 1 to each bit field if it is not currently locked .... this seems like the solution for what you described?

Kurt

-- 


----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com

"Adrian Scott-Day" <adrian.scott.day_at_gmail.com> wrote in message
news:1281ac97.0412010905.27eaa670_at_posting.google.com...

> Could anyone shead some light on this problem that I'm faced with.
>
> I have a stored procedure that has 2 parameters. The first is the
> primary key for the table that is to be updated. The second is an
> integer. This integer is actually a bitwise status flag.(1=locked,
> 2=reviewed, 4=invalid...)
>
> The issue that I am facing is that I need to change the value for a
> large number of fields within this particular table, but only modify
> the relevant bits.
> For example record1 has a value of 4 in it's statusA field which means
> it is marked as invalid but not locked and not reviewed.
> Record1 has a value of 5 in it's statusB field which means it is
> marked as invalid and locked but not reviewed.
> The stored procedure then passes the primary key to select record1 and
> an integer value of 1, thereby indicating that the "locked" bit of the
> statusA and statusB fields should be set.
>
> How can I do this?
Received on Wed Dec 01 2004 - 16:20:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US