Re: SQL Statement Priority
Date: Thu, 24 Jan 2008 07:22:37 -0600
Message-ID: <ffb96860801240522y18919783s3ae60994f55a9128@mail.gmail.com>
Replace your select * with a column list and then use either decode or case
to get what you want.
Allan
On Jan 24, 2008 6:46 AM, Cristian Chelemen <cristian_chelemen_at_yahoo.com> wrote:
> Hi ALL!
> I have a pretty nagging thing that bothers me for 2 days now and I want to
> find out your oppinion about it.
>
> *Prerequisites:*
> CREATE TABLE p_emb_op_types(inst_id VARCHAR2(10 BYTE) NOT NULL,
> op VARCHAR2(20
> BYTE) NOT NULL,
> status
> NUMBER NOT NULL);
> CREATE UNIQUE INDEX uk_emb_op_types ON p_emb_op_types (inst_id, op,
> status);
> INSERT INTO p_emb_op_types (inst_id, op, status) VALUES ('*', 'ISSUE',
> 60);
> INSERT INTO p_emb_op_types (inst_id, op, status) VALUES ('2', 'ISSUE',
> 70);
> COMMIT;
>
> I want to build a *SQL *statement (will be part of a cursor) and I do not
> want to create a function for this... below italic pseudocode
>
> SELECT *
> FROM p_emb_op_types
> WHERE op = 'ISSUE'
> AND inst_id =* (IF ¶m exists in inst_id column where op = 'ISSUE'*
> * THEN ¶m*
> * ELSE '*'*
> * END IF;)*
>
> And I'll give you some examples of what it'll do:
> if ¶m = '2' then retrieve '2', 'ISSUE', 70 line
> if ¶m = '3' then retrieve '*', 'ISSUE', 60 line
> if ¶m = '*' then retrieve '*', 'ISSUE', 60 line
>
> I hope that I made myself clear on this issue.
>
> Cristian
>
>
> ------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.<http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
>
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Jan 24 2008 - 07:22:37 CST