Oracle: Use NVL() to convert a null value into another value.
来源:互联网 发布:黄金行情走势软件 编辑:程序博客网 时间:2024/05/01 21:46
When you retrieve data from oracle database,
when some records has null value in some columns,
if you want to display the records more meaningful,
with the columns whose value is null being displayed with a meaningful string,
you can turn help to one of the oracle's built-in functions: NVL().
NVL() allows you to convert a null value into another value.
NVL() accepts two parameters: a column, and the value that should be substituted.
In the following example, NVL() is used to convert a null value in the "name " column to the string "The name for this fruit is unknown".
Data preparation:
create table fruit
(
id NUMBER(4) primary key,
name VARCHAR2(150)
);
insert into fruit values(1, 'Apple' );
insert into fruit values(2, 'Banana');
insert into fruit values(3, 'Pear' );
insert into fruit values(4, null);
commit;
select * from fruit; And the output is:
id name
1 Apple
2 Banana
3 Pear
4 null
select id, NVL(name,'The name for this fruit is unknown')name from fruit; And the output is:
id name
1 Apple
2 Banana
3 Pear
4 The name for this fruit is unknown
- Oracle: Use NVL() to convert a null value into another value.
- convert dp to a pixel value
- Optional int parameter 'folderId' is not present but cannot be translated into a null value due to b
- Optional int parameter 'id' is present but cannot be translated into a null value due to being decla
- Optional int parameter 'page' is present but cannot be translated into a null value due to being dec
- Optional int parameter 'version' is present but cannot be translated into a null value due to being
- Optional int parameter 'id' is present but cannot be translated into a null value due to being decla
- Optional int parameter 'rip' is present but cannot be translated into a null value due to being decl
- Optional int parameter 'topicId' is present but cannot be translated into a null value due to being
- Optional int parameter 'id' is present but cannot be translated into a null value due to being decla
- Optional int parameter 'pageNumber' is present but cannot be translated into a null value due to bei
- Convert DateTime Value into String in Mysql
- Convert YYYYMMDD string date to a datetime value
- hibernate:Null value was assigned to a property of primitive
- 【hibernate】Null value was assigned to a property of primitive
- Null value was assigned to a property of primitive
- Null value was assigned to a property of primitive ...
- HibernateSystemException: Null value was assigned to a property of primitive ...
- 自定义控件属性(attr.xml,TypedArray)
- 将后台窗口激活到前台的方法
- JDBC连接各种数据库的方式
- 单链表逆序
- form表单中get与post的区别
- Oracle: Use NVL() to convert a null value into another value.
- 如何将一个某个窗口提到最顶层
- struts2中ActionContext是什么东东???
- JAVA中的== equals hashcode问题
- LayoutInflater和findViewById()
- Javascript向Select中添加option(备忘)
- C#通过webbrowser控件与javascript交互
- Linux世界开启传送门-预备第二天
- OpenGL教程(2):编程初步