Oracle custom function: using the dot code converted into separator layer code encoding format

Maintain a legacy system, only the coding table design, and no other sort related field, and then there is a problem according to the coding sequence disorder ordering.

Specific solution is the use of PL / SQL write a custom function that uses the dot delimiter turn into coded hierarchical coding code format, such as turn into 001,001,001 1.1.1.1.

    RETURN VAR_ZERO_CODE;
  END;

After you've created your self-defined functions, it can be used to use (defined here is my 10-bit level code).

SELECT POINT_CODE_INTO_ZARO_CODE('1.2.3') CODE FROM DUAL; -- 000000000100000000020000000003
SELECT POINT_CODE_INTO_ZARO_CODE('110') CODE FROM DUAL; -- 0000000110

Thus, when in the ordering of the encoded ORDER BY clause plus conversion, can be achieved properly sorted.

Guess you like

Origin www.linuxidc.com/Linux/2019-11/161533.htm