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

Home -> Community -> Usenet -> c.d.o.server -> Re: opposite of oracle decode

Re: opposite of oracle decode

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Thu, 6 Oct 2005 09:52:25 -0400
Message-ID: <OeOdnQmL9t6AsdjenZ2dnUVZ_sqdnZ2d@comcast.com>

"Adam Sandler" <corn29_at_excite.com> wrote in message news:1128605177.591206.250530_at_z14g2000cwz.googlegroups.com...
>
> William Robertson wrote:
>> Adam Sandler wrote:
>> > Hello,
>> >
>> > New to working with Oracle here and I cannot find the answer to my
>> > question. I have a table that stores a char e.g., 1, 2, or 3. Those
>> > chars reflect that statuses of reports. 1 = open, 2 = review, 3 =
>> > closed. When querying I can use decode so the user sees open, review,
>> > or closed instead of the less meaningful 1, 2, or 3.
>> >
>> > My question is what if I want to write to the DB? If the user is using
>> > a GUI to interface with the DB and they see open, review, or closed in
>> > the GUI's list of options, I need to trnaslate open, review, or closed
>> > into 1, 2, or 3 to get it into the DB.
>> >
>> > Is there an encode function? Searching on that didn't help... is there
>> > something the opposite of "decode"?
>> >
>> > P.S. This isn't my DB desgin. It is what I was given to work with.
>> >
>> > Thanks!
>>
>> er, DECODE?
>
> Decode lets one write to the DB? I've never seen an example of decode
> used without a select in front. That would imply querying right? My
> question wasn't about retrieving data but writing new records. I'd
> like to know if there is a oracle function that is the opposite of
> decode. I was hoping to avoid doing any mapping, when doing inserts,
> programtically.
>

decode is a function, which is a type of an expression

expressions can be used anywhere in SQL or PL/SQL where a literal value or a column value can be used (they cannot be used as an assignment target)

so decode can be used in SELECT, INSERT, UPDATE and DELETE, in the SELECT, VALUES, SET, ORDER BY, WHERE, GROUP BY, and HAVING clauses, etc.

as mentioned before, DECODE is the opposite of DECODE -- it depends on how you supply the parameters, as illustrated in other posts.

++ mcs Received on Thu Oct 06 2005 - 08:52:25 CDT

Original text of this message

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