Solved

PL/SQL CASE Statement

Posted on 2009-05-05
3
417 Views
Last Modified: 2013-12-07
I keep getting errors on this.  Can someone help me write this statement correctly?  
Basically, if my first result ends in "0", then I want the first letter of the last name, else I want the last number of the Subscriber ID.


CASE substr(O221762."Subscriber_ID",9,1)

     WHEN "0" THEN  substr(O221762."Mbr_Last_Name",1,1) AS "CM_ID"

     ELSE substr(O221762."Subscriber_ID",9,1) AS "CM_ID"

END

Open in new window

0
Comment
Question by:Luis5011
  • 2
3 Comments
 
LVL 14

Expert Comment

by:ajexpert
ID: 24306765
How abt this?


 CASE substr(O221762.Subscriber_ID,9,1)

     WHEN '0' THEN  substr(O221762.Mbr_Last_Name,1,1) AS "CM_ID"

     ELSE substr(O221762.Subscriber_ID,9,1) AS "CM_ID"

END

 

Open in new window

0
 

Author Comment

by:Luis5011
ID: 24306962
Nope.  Tells me I have a missing key word.
0
 

Accepted Solution

by:
Luis5011 earned 0 total points
ID: 24307115
I figured it out.  I used the following format and added the " " around the field name, which I hadn't done.

CASE
     WHEN substr(O221762."Subscriber_ID",9,1)= 0 THEN  substr(O221762."Mbr_Last_Name",1,1)
     WHEN substr(O221762."Subscriber_ID",9,1)<>0 THEN  substr(O221762."Subscriber_ID",9,1)
END  AS "CM_ID",
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.

Join & Write a Comment

Suggested Solutions

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

758 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

18 Experts available now in Live!

Get 1:1 Help Now