zoukankan      html  css  js  c++  java
  • IsNull Function in PeopleSoft MetaSQL

    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;

  • 相关阅读:
    ES5、6对异步事件的处理方式
    SQL技巧
    前端技巧
    docker start 启动失败,logs 没有日志
    mysql使用存储过程insert
    Spring 手动回滚事务/提交事务,及通过
    mysql触发器trigger 实例详解
    @PostConstruct 之NullException
    springboot 2 多数据源 hikari 连接池
    swagger 日期Date
  • 原文地址:https://www.cnblogs.com/lei1016cn/p/2475964.html
Copyright © 2011-2022 走看看