Conversion of code value set in Oracle-field into row record

In the database, there may be a scenario where a single field stores multiple codes and uses critical separators. In use, the code value needs to be split into multiple lines for use. 
After obtaining the code value in the following way, it can be used according to the scene.
-
Create six rows SELECT rownum AS COL from Dual Connect by rownum <= . 6 ; - Get the number of rows in the set of code values the SELECT ' Obtaining ' || rownum || ' code ' from Dual Connect by rownum <= LENGTH ( ' Code 1, Code 2, Code 3 ' ) - LENGTH (regexp_replace ( ' Code 1, Code 2, Code 3 ' , ', ' , ' ' )) + 1 ; - obtaining a code value set in rows and converted the SELECT the REGEXP_SUBSTR ( " Code 1, Code 2, Code. 3 ' , ' [^,] + ' , 1 , rownum) from Dual connect by rownum <= LENGTH ( ' Code 1, Code 2, Code 3 ' ) - LENGTH (regexp_replace ( ' Code 1, Code 2, Code 3 ' , ' , ' , '' )) + 1 ;


 

Guess you like

Origin www.cnblogs.com/yangjn/p/12693458.html