Solved

Oracle Case statement problem

Posted on 2012-12-27
4
594 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 69

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pivoting oracle table 9 74
Oracle SQL Developer - SubString 2 31
SP result not being displayed 5 44
Finding Where Clause Value in SQL Views and SP 21 43
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

730 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