IsNull Function in PeopleSoft Meta-SQL

本文深入解析了三种数据库环境下处理NULL值的方法:InMSSQLServer使用ISNULL、OracleDatabase使用NVL以及PeopleSoftMeta-SQL使用%COALESCE函数。通过实例代码展示每种方法的具体应用,并解释其工作原理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In MS SQL Server, sometimes we will use queries like this to avoid the NULL value to be populated

   1: SELECT ISNULL(TABLE1.COLUMN1,'IT IS NULL')
   2: FROM TABLE1

Similarly, in Oracle Database, we can use this:

   1: SELECT NVL(TABLE1.COLUMN1,'IT IS NULL')
   2: FROM TABLE1

However, in PeopleSoft Meta-SQL, we shall use the function %COALESCE to do the same thing

   1: SELECT %COALESCE(TABLE1.COLUMN1,'IT IS NULL')
   2: FROM TABLE1

Below is the syntax explanation from People Book.

Click to jump to top of pageClick to jump to parent topic
%COALESCE

Syntax


 

%COALESCE(expr1, expr2, ...)

Description

Use the %COALESCE function to return the first non-null argument provided to the function.

Note. This meta-SQL function is not implemented for COBOL.

Parameters

expr1. . .exprn

Specify the expressions to check.

Note. You cannot specify bind parameters using these expressions.

Example

The following example uses the PRODUCT_INFO table to organize a clearance sale of products. It gives a 10 percent discount to all products with a list price. If there is no list price, the sale price is the minimum price. If there is no minimum price, the sale price is 10.


 

SELECT product_id, list_price, min_price, %COALESCE(0.9*list_price, min_price, 10)⇒ "Sale" from PRODUCT_INFO where SUPPLIER_ID = 6009;

转载于:https://www.cnblogs.com/lei1016cn/archive/2012/04/29/2475964.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值