Solved

Oracle Case statement problem

Posted on 2012-12-27
4
588 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

863 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

27 Experts available now in Live!

Get 1:1 Help Now