oracle中length()与lengthb()区别

oracle中length()与lengthb()区别

SQL> select length('啊呀') from dual;

LENGTH('啊呀')
--------------
             2

SQL> select lengthb('啊呀') from dual;

LENGTHB('啊呀')
---------------
              4

区别:length求得是字符长度,lengthb求得是字节长度。
CREATE OR REPLACE FUNCTION fun_ifcn (
V_col in varchar2
)
RETURN NUMBER IS
V_yn  number;
/******************************************************************************
  This function is to judge the V_col is cn or not!
  Note:
         0:not
         1:yes
  Author:Rolland
  Date : 2009-01-15 18:16
******************************************************************************/
BEGIN
     IF length(V_col)=lengthb(V_col) THEN
         V_yn:=0;
     ELSE
         V_yn:=1;
     END IF;  
     RETURN V_yn;
    
   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       NULL;
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END fun_ifcn;

你可能感兴趣的:(oracle,sql,exception,function,logging,fun)