Subtype normalization Data Type

Source: Internet
Author: User
Subtype is a type alias. If you want to change it, you only need to modify the definition of one place. Code No changes required
Maybe we are used to variables to represent unknown, but we are not used to variables to represent variable types.
Subtype plays a role in this way. It can use a new type variable to represent a known type.
If the variable you define is likely to need to change the variable type, using subtype can greatly reduce the amount of modification to your code.
There are many benefits, such as reusing, reducing dependencies between modules, and reducing maintenance costs.
For example,
Assume that I have a table: book, which has a field: page_count. The type is number (2)
Now I want to write Program To display the pages of all books I have currently written.
I can write it like this:
Declare
Rochelle total book. page_count % type;
This is fine, but what if all my pages exceed 100?
I can also write:
Declare
Rochelle total number (10 );
This is a hard coding method, and think is annoying.
This does not work either? That doesn't work either? How are you doing? Haha ....
In fact, we can do this:
Create or replace package pkg_book
As
Subtype total_count is number (10 );
End pkg_book;
Then,
Declare
Rochelle total pkg_book.total_count;

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.