473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,396 developers and data experts.

GENERAL FUNCTIONS

amitpatel66
2,367 Expert 2GB
GENERAL Functions:

NVL(column_name, m) - Returns m if column_name value is NULL
Expand|Select|Wrap|Line Numbers
  1. SELECT NVL(empno,0) FROM emp -- returns 0 if empno is NULL
  2.  
NVL2(column_name,c1,c2) - Returns c1 if column_name IS NOT NULL and c2 if column_name IS NULL
Expand|Select|Wrap|Line Numbers
  1. SELECT NVL2(empno,empno,'NO EID') from dual -- returns empno if empno IS NOT NULL else returns 'NO EID'
  2.  
NULLIF(column_name,value) - Returns NULL, IF column_name = value
Expand|Select|Wrap|Line Numbers
  1. SELECT NULLIF(empno,1) FROM emp -- returns NULL IF empno = 1
  2.  
COALESCE(column1,column2,column3,column4) - Returns columns2 if column1 IS NULL, else returns column3 if column2 is also NULL and so on. All the columns should be of same data type
Expand|Select|Wrap|Line Numbers
  1. SELECT COALESCE(ename,first_name,last_name,'NO NAME') from emp -- returns first_name IF ename IS NULL, IF first_name IS also NULL, then returns last_name, IF last_name IS also NULL, then returns 'NO NAME'
  2.  
DECODE(column_name,val1,ret_val,val2,ret_val2,ret_ val3) - Returns ret_val1 IF column_name = val1 ELSE Returns ret_Val2 IF column_name = val2 ELSE Returns ret_val3
Expand|Select|Wrap|Line Numbers
  1. SELECT DECODE(empno,1,'PM',2,'BM','EMP') FROM emp -- returns 'PM' if empno = 1 ELSE IF empno = 2 then returns 'BM' ELSE returns 'EMP'
  2.  
CASE(column_name) - CASE can be used in PLSQL as well as SQL statement.

Expand|Select|Wrap|Line Numbers
  1. SELECT empno,ename,
  2. (CASE WHEN (empno = 1) THEN 'PM'
  3.           WHEN (empno = 2) THEN 'BM'
  4.           ELSE 'EMP' END) Position
  5. FROM emp
  6.  
Sep 17 '07 #1
0 5668

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: D. Alvarado | last post by:
On my Fedora Core 2 Linux dev box, I have installed mcrypt and compiled PHP with the --with-mcrypt option. I am concerned that when I move to another hosting enviornment mcrypt will not be...
20
by: syd | last post by:
In my project, I've got dozens of similar classes with hundreds of description variables in each. In my illustrative example below, I have a Library class that contains a list of Nation classes. ...
1
by: Andrew MacLean | last post by:
Hello all, I am fairly new to .NET, but not to VB. I have a couple of questions. 1. Shared Code Base I have a solution with several different applications within it. Many of the...
7
by: Felix Kater | last post by:
Hi, when I need to execute a general clean-up procedure (inside of a function) just before the function returns -- how do I do that when there are several returns spread over the whole function?...
1
by: jason | last post by:
Hello everyone, I have some general questions about the DataTable object, and how it works. Moderately new to C#, I have plenty of texts describing the language, but not so much to reference...
6
by: Alex | last post by:
Hello I am intersting in developing and my background is VBA used in Excel and a brief intro to Java. I am interested in learning beyond VB and feel that C++ would be a very good language to...
25
by: lovecreatesbeauty | last post by:
Could you talk something about the general rules on the interface (function) design in C program that recognized publically? Or introduce some good advice of yourself. How do you think about...
12
by: Arash Partow | last post by:
Hi all, I've ported various hash functions to python if anyone is interested: def RSHash(key): a = 378551 b = 63689 hash = 0
8
by: Razzbar | last post by:
I've been trying to write a general buffer function that looks something like this: function buffer($arg){ ob_start(); $arg; return ob_get_clean(); } Note that the intention is for this to...
22
by: Neil Gould | last post by:
Or... when is a script not a script? I have several modules for managing different aspects of our club's website, most of which are multi-page. Does setting such things as server.ScriptTimeout...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.