Oracle character bitwise OR Function

Source: Internet
Author: User

/*
Function Name: Oracle character bitwise OR Function
Parameter constraints: the length of P1 and P2 must be consistent.
*/
Create or replace function f_bitor (p1 in string, P2 in string) return varchar2 is
Result varchar2 (16 );
T_p number (3 );
R_p varchar2 (16 );
P_P number (3 );
C_1 char (1 );
C_2 char (1 );
Begin
T_p: = length (P1 );
P_P: = 0;
Loop
-- Exit condition
Exit when P_P = t_p;
-- Value by bit
C_1: = substr (P1, P_P, 1 );
C_2: = substr (P2, P_P, 1 );
-- Assign values after comparison
If C_1> C_2 then
R_p: = R_p | to_char (C_1 );
Elsif C_1 <C_2 then
R_p: = R_p | C_2;
Else -- equal
R_p: = R_p | C_1;
End if;
-- Offset
P_P: = P_P + 1;
End loop;
Return (R_p );
End f_bitor;

Related Article

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.