Oracle NULL column and PL./SQL Execution Experiment

Source: Internet
Author: User

Oracle NULL column and PL./SQL Execution Experiment

Today, we have some experiments on Oracle NULL values. We will discuss how to insert NULL values.

1. You can insert ''or NULL in PL/SQL, provided that the column is allowed to be empty.

2. You can perform a series of database operations on NULL. For example:

Select round (TO_NUMBER (MAX (A. IN_STATION_TIME)-SYSDATE) * 24 FROM SFISM4.R _ WIP_TRACKING_T A WHERE

A. IN_STATION_TIME IS NULL

Conclusion: The corresponding TO_NUMBER (NULL) is also feasible, and MAX is also feasible, no problem.

3. Return to the topic. The original format of SQL is as follows:

Insert into SFISM4.R _ DT_PCB_OVERTIME_T F

(F. SERIAL_NUMBER,

F. MODEL_NAME,

F. LINE_NAME,

F. PRODUCTION_TIME,

F. INTERCEPT_TIME,

F. EXPRIATUION_HOUR,

F. STATE_FLAG,

F. SEND_USER)

(SELECT 'co111111111111111111 ',

'Niubi1 ',

'123 ',

NVL (NULL, MAX (A. IN_STATION_TIME )),

SYSDATE,

NVL (ROUND (TO_NUMBER (MAX (A. IN_STATION_TIME)-SYSDATE) * 24, '0 '),

'1 ',

'1'

FROM SFISM4.R _ WIP_LOG_T E

Where e. SERIAL_NUMBER = 'co111111111') and e. GROUP_NAME = 'smts ')

Result: After partial execution, no Insert. Insert operation is performed for one entry. According to the subquery, if the subquery is empty, nothing is inserted.

4. the climax -- after removing the WHERE clause in the subquery, that is, the SELECT condition must have a value, and insert all records in Table E. ah, thanks to the test database, the data volume is small, but it is also executed for 5 s. okay, exception. delete all! We can see that we still need to be careful when inserting the result set. Otherwise, we will put the amount of junk data into reality.

5. Regression intention. The final determination of NULL values will prevent unexpected large amounts of data.

-------------------------------------- Split line --------------------------------------

Rlwrap

SQLPLUS spool to dynamic Log File Name

Oracle SQLPLUS prompt settings

Accelerate SQL return by setting SQLPLUS ARRAYSIZE (row prefetch)

PL/SQL Developer Practical Skills

-------------------------------------- Split line --------------------------------------

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.