Re: Display date in oracle based on flag

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Tue, 16 Oct 2001 19:18:57 +0200
Message-ID: <tsorc0fcs08nab_at_corp.supernews.com>


"sgupta" <sugandha_g_at_yahoo.com> wrote in message news:62deede6.0110160534.597afdae_at_posting.google.com...
> My apologies if this seems elementary but I am new . I have a oracle
> table with fields
>
> Date sale # Flag_book Flag_audio Book Audio
> XXX 1 Y Y 3 1
> XXX 2 Y N 3 0
>
> I want to use ap to display it as this on a webpage. Any help with
> queries is appreciated. Thanks in advance!
>
> Date Sale # item_type no
> XXX 1 book 3
> XXX 1 audio 1
> XXX 2 book 3
>
> Thanks very much. Any help appreciated

I think the best solution is to revise the table design which is, sorry to say so, lousy.
It is lousy because you will end up using this construct decode(flag_book,'Y','book',decode(flag_audio,'Y', 'audio','?????')) *everywhere*
also: do you see what is going to happen? 1 if both flags are set to N, you have an unknown type, and I think currently you don't cater for that
2 if you need to store 'video' and you decide to use yet another flag, the disaster will become even bigger.
You need to normalize your design.
The output you want should be the design of your table.

Hth,

Sybrand Bakker
Senior Oracle DBA Received on Tue Oct 16 2001 - 19:18:57 CEST

Original text of this message