Solved

Oracle Case statement problem

Posted on 2012-12-27
4
584 Views
Last Modified: 2012-12-27
Im relatively new to Oracle query syntax so can you help me out with the Case statement.

Select SECTION_ID, SECTION_TYPE, SECTION_ORDINAL, SECTION_TABLE_CELL,
  CASE SECTION_TYPE
    WHEN LINKLIST
      THEN (SELECT LINK_LIST_NAME FROM OMNI_ENT_LINKLIST WHERE LINKLIST_ID = SECTION_ID)
    WHEN LINE
      THEN (SELECT LINK_ID FROM OMNI_ENT_LINK WHERE LINK_ID = SECTION_ID)
    WHEN HEADER
      THEN (SELECT LINK_ID FROM OMNI_ENT_HEADER WHERE HEADER_ID = SECTION_ID)
    WHEN PARAGRAPH
      THEN (SELECT LINK_ID FROM OMNI_ENT_PARAGRAPH WHERE LINK_ID = SECTION_ID)
    ELSE ''
  END AS SECTION_ENTITY
FROM OMNI_ENT_PAGE_CONTENT
0
Comment
Question by:jknj72
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 38724545
What's the error you're getting ?

Here's a reference to using the CASE statement:  http://www.techonthenet.com/oracle/functions/case.php

Assuming that LINKLIST, LINE, HEADER and PARAGRAPH are valid values of column SECTION_TYPE, enclose the values in quotes:

CASE SECTION_TYPE
WHEN 'LINKLIST' then

etc

Try that and if you're still getting errors, can you come back with that the error message is ?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38724647
I would prefer to not use a case here:
Select SECTION_ID, SECTION_TYPE, SECTION_ORDINAL, SECTION_TABLE_CELL,
   types.ID AS SECTION_ENTITY
FROM OMNI_ENT_PAGE_CONTENT
Left Join  (
  select 'LINKLIST' as Type, Link_List_Name as ID from Omni_Ent_Linklist
  union
  select 'LINE', Link_ID from Omni_Ent_Link
  union
  select 'HEADER', Link_ID from Omni_Ent_Header
  union
  select 'PARAGRAPH', Link_ID from Omni_Ent_Paragraph ) types
on types.type = Section_Type

Open in new window

0
 

Author Comment

by:jknj72
ID: 38724694
yes that worked, glad I wasnt far off....Thanks
0
 

Author Closing Comment

by:jknj72
ID: 38724699
thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now