Oracle inversion Function

Source: Internet
Author: User
Oracle provides a reverse inversion function, reverse, but this function cannot be used for grouping inversion. This article provides a function that can be used for grouping inversion, as shown below:

Oracle provides a reverse inversion function, reverse, but this function cannot be used for grouping inversion. This article provides a function that can be used for grouping inversion, as shown below:

Oracle provides a reverse inversion function reverse, but this function cannot be used for grouping inversion. This article provides a function that can be used for grouping inversion, as shown below:

Create or replace function REVERSE_F (p_str VARCHAR2, p_delimiter VARCHAR2: = '')
RETURN VARCHAR2 IS
V_return VARCHAR2 (4000 );
Vp_str VARCHAR2 (4000): = p_str;
V_idx number;
Vp_len number: = length (p_delimiter );
BEGIN
If (p_delimiter is null) then
Select reverse (p_str) into v_return from dual;
Else
Loop
V_idx: = instr (vp_str, p_delimiter );
If (v_idx = 0) then
V_return: = vp_str | v_return;
Exit;
Elsif (v_idx = 1) then
V_return: = substr (vp_str, 1, vp_len) | v_return;
Vp_str: = substr (vp_str, vp_len + 1 );
Else
V_return: = substr (vp_str, 1, v_idx-1) | v_return;
Vp_str: = substr (vp_str, v_idx );
End if;
End loop;
End if;
RETURN v_return;
END REVERSE_F;

Detailed examples of Oracle function GREATEST Functions

Single-row conversion functions of Oracle Functions

Oracle functions that generate dynamic prefixes and auto-increment numbers

Replace () for Oracle Functions ()

Oracle Functions

Differences in case and decode usage and Performance Comparison of Oracle Functions

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.