Oracle PLSQL Demo - 22.查看字符串的长度[lengthb, length],判断字符串是否包含中文

--Count the length of string
select lengthb(‘select * from scott.emp‘) as countted_by_byte, length(‘select * from scott.emp‘) as countted_by_char from dual;

--For some character encoding, the length() and the lengthb() is same in english
--you may use this feature to check whether the string constains the chinese char
declare
  v_char varchar2(50) := ‘hello world你好‘;
begin

  if lengthb(v_char) = length(v_char) then
    dbms_output.put_line(‘it have not chinese...‘);
  else
    dbms_output.put_line(‘it have chinese...‘);
  end if;

end;
时间: 2024-12-19 17:35:39

Oracle PLSQL Demo - 22.查看字符串的长度[lengthb, length],判断字符串是否包含中文的相关文章

c# 判断字符是否是全角, 获取字符串的字节数 , 获取字符串指定长度字节数的字符串

1 Encoding.Default.GetByteCount(checkString);  =2 全角 =1 半角 /// <summary> /// 获取字符串的字节长度 /// </summary> /// <param name="str"></param> /// <returns></returns> public static int GetStringByteLength(this string s

灵魂拷问:Java如何获取数组和字符串的长度?length还是length()?

限时 1 秒钟给出答案,来来来,听我口令:"Java 如何获取数组和字符串的长度?length 还是 length()?" 在逛 programcreek 的时候,我发现了上面这个主题.说实话,我当时脑海中浮现出了这样一副惊心动魄的画面: 面试官老马坐在我的对面,地中海式的发型令我敬佩有加.尽管略显疲惫,但他仍然自信地向我抛出了上面这个问题.稍稍迟疑了一下,我回答说:"数组用 length,字符串用 length 跟上小括号".老马不愧是面试中的高手,一瞬间就从我的

判断某个字符串是否出现在另一个字符串的最后面 或者 判断字符串1是否以字符串2结尾

判断字符串1是否以字符串2结尾 $str1 = "我爱你,亲爱的中国";$str2 = "中国";if( strrchr($str1,$str2)==$str2 )echo "Y";else echo "N"; 判断字符串1是否以字符串2结尾 stripos() - 查找字符串在另一字符串中第一次出现的位置(不区分大小写) strpos() - 查找字符串在另一字符串中第一次出现的位置(区分大小写) strrpos() - 查

Oracle PLSQL Demo - 24.分隔字符串function

-- refer: -- http://www.cnblogs.com/gnielee/archive/2009/09/09/1563154.html -- http://www.cnblogs.com/yudy/archive/2012/07/18/2597874.html CREATE OR REPLACE TYPE ty_str_split IS TABLE OF VARCHAR2 (4000); CREATE OR REPLACE FUNCTION splitstr(p_string I

Oracle PLSQL Demo - 03.流程判断[IF ELEIF ELSE]

declare v_job varchar2(50) := 'Programmer'; v_sal number; begin if v_job = 'Programmer' then v_sal := 6000; elsif v_job = 'Senior Programmer' then v_sal := 8000; else v_sal := 10000; end if; dbms_output.put_line(v_sal); end;

Oracle PLSQL Demo - 18.01管道function[查询零散的字段组成list管道返回]

--PACKAGE CREATE OR REPLACE PACKAGE test_141213 is TYPE type_ref IS record( ENAME VARCHAR2(20), WORK_CITY VARCHAR2(20), SAL NUMBER(10)); TYPE t_type_ref IS TABLE OF type_ref; FUNCTION retrieve(v_name varchar2) RETURN t_type_ref PIPELINED; END test_14

Oracle PLSQL Demo - 16.弱类型REF游标[没有指定查询类型,已指定返回类型]

declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; rec_emp scott.emp%RowType; v_sql varchar2(100) := 'select * from scott.emp t'; begin Open cur_variable For v_sql; Loop fetch cur_variable InTo rec_emp; Exit When cur_variable

Oracle PLSQL Demo - 20.弱类型REF游标[没有指定查询类型,也不指定返回类型]

declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; v_ename varchar2(10); v_deptno number(2); v_sal number(7,2); v_sql varchar2(100) := 'select t.ename, t.deptno, t.sal from scott.emp t'; begin Open cur_variable For v_sql; Loo

Oracle PLSQL Demo - 19.管道function[查询整表组成list管道返回]

create or replace function function_demo RETURN emp PIPELINED as Type ref_cur_emp IS REF CURSOR RETURN emp%RowType; cur_emp ref_cur_emp; rec_emp cur_emp%RowType; begin Open cur_emp For select * from emp t; Loop fetch cur_emp InTo rec_emp; Exit When c