Less efficient datatypes cause interchangeability issues

Software ResiliencyProgramming Best Practices

Why you should care

Every constant, variable, and parameter has a datatype (or type) which specifies a storage format, constraints, and valid range of values. PL/SQL provides a variety of predefined datatypes which tend to be inefficient in nature.

It’s recommended to use efficient practices over inefficient types to ensure the code runs efficiently and interchangably across platforms. It also ensures that the code is not complex in the process


Business Impacts

Using less efficient types is absolutely risky for the code because it’s name is certainly a giveaway. It is best practice to avoid less efficient types so that the code can be more productive.

Production Risk
5362

How we detect

This code insight shows that PLS_INTEGER should be used for its efficiency, avoid type conversion, and constrained types when its possible.
PLS_INTEGER is defined in the STANDARD package as a subtype of BINARY_INTEGER. PLS_INTEGER operations use machine arithmetic, so they are generally faster than NUMBER and INTEGER operations. Also, prior to Oracle Database 10g, they are faster than BINARY_INTEGER. In Oracle Database 10g, however, BINARY_INTEGER and PLS_INTEGER are now identical and can be used interchangeably.
The types NATURALN and POSITIVEN are defined to be NOT NULL subtypes of NATURAL and POSITIVE, respectively; thus, you will incur the performance penalty described in the NotNullVariables alert description when you use them.
5362

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.

See featuresHow it works