Home
Scale should not be specified for float types
Description
The Pl_Sql code rule "Scale should not be specified for float types" means that when defining a float type in Pl_Sql, the scale (the number of digits after the decimal point) should not be specified. This is because float types are designed to store numbers with a variable number of digits after the decimal point, and specifying a scale would limit the number of digits that can be stored.
Key Benefits
- Precision: Scale should not be specified for float types as it allows for a greater degree of precision when dealing with decimal values.
- Flexibility: Float types do not require a scale to be specified, allowing for greater flexibility when dealing with different types of data.
- Efficiency: Not specifying a scale for float types can lead to more efficient storage and retrieval of data.
Non-compliant Code Example
Create TABLE VENDOR
(
ID number(10) NOT NULL,
NAME NVARCHAR2(75),
ADDRESS NVARCHAR2,
Landmark VARCHAR2,
TurnOver FLOAT(12,2), --Non compliant code (Scale specified in the float types)
CONSTRAINT pk_vendor PRIMARY KEY (ID)
);
Compliant Code Example
Create TABLE VENDOR
(
ID number(10) NOT NULL,
NAME NVARCHAR2(75),
ADDRESS NVARCHAR2,
Landmark VARCHAR2,
TurnOver FLOAT(12), --Compliant code
CONSTRAINT pk_vendor PRIMARY KEY (ID)
);