Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

left function

Posted on 2004-11-16
5
Medium Priority
?
29,878 Views
Last Modified: 2012-06-27
how do i do a left function in oracle..
stra='abcderrrrrr'
 left([stra],5) =abcde(I would do it this way in vba but inoracle how do i do it



also how do it do multiple if consitions in oracle..
decode works for 1 or 2 but for 10 it does not..
0
Comment
Question by:eileenbanik
5 Comments
 
LVL 3

Accepted Solution

by:
ToddBarry earned 1000 total points
ID: 12597604
substr(stra, 1, 5)

If you are on a recent version of Oracle, you can use the CASE statement for multiple conditions.

select case
  when x = 1 then ...
  when user = 'XYZ'  then ...
end
from ...

select case empno
  when 1 then ...
  when 2 then ...
  else
end
from ...
0
 
LVL 23

Expert Comment

by:paquicuba
ID: 12597811
Of course decode works for more than 1 or 2 conditions, check this out:

http://www.experts-exchange.com/Databases/Oracle/Q_21207130.html


0
 
LVL 23

Expert Comment

by:paquicuba
ID: 12597882
SQL> select decode(decode(decode(sysdate,'16-NOV-04','OK','NOT OK'),'OK',SYSDATE,SYSDATE-1),SYSDATE,DUMMY,'Y') FROM DUAL;

D
-
X

Give me 500 points and I'll nest 20 decodes for you...
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 12597916
>> how do i do a left function in oracle..

Use substring:
  select 'Got it' from dual where  substr('abcdefghijkl',1,5) = 'abcde';

>>also how do it do multiple if consitions in oracle.

Could you provide a little more detail on the specifics of this requirement?
0
 

Author Comment

by:eileenbanik
ID: 12618250
All the solutions solve the problem,Thanks to all of You. I would max points to everybodys answer thank you
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

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…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

564 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