Oracle's easy-to-make set of errors and tricks

Source: Internet
Author: User

Introduction

This article records the pitfalls of Oracle programming that are easily encountered in daily development and some usage tips that are not updated regularly.

1.sum (), Max (), Min (), AVG () and other functions get null values

DeclareN_num Number(5):="';beginSelect sum(1) intoN_num fromDualwhere 1=2; N_num:=N_num+2;d Bms_output.put_line (n_num);End;

The code above describes a scenario that we develop on a daily basis, summing up the data of a table, and then computing it in various ways. The normal situation is no problem, but the sum table has no data, we will get a null value, and then cause a series of subsequent calculations are null values,

Cause business errors.

Workaround: Add the NVL () function to handle this exception, as follows:

DeclareN_num Number(5):="';beginSelectNvlsum(1),0) intoN_num fromDualwhere 1=2; N_num:=N_num+2;d Bms_output.put_line (n_num);End;

Oracle's easy-to-make set of errors and tricks

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.