----字符串遍历
create or replace view table_test as (select '中国加油' name ,'ZGJY' value from dual);
select * from table_test;
拼接字符串jqgc没有引号
select level,
substr(a.name, level, 1) as jqhz,
substr(a.value, level, 1) as jqpy,
'substr(' || a.name || ',' || level || ',1)' jqgc
from table_test a
connect by level <= length(a.name);
正确写法一
select level,
substr(a.name, level, 1) as jqhz,
substr(a.value, level, 1) as jqpy,
'substr('''|| a.name ||''',' || level || ',1)' jqgc
from table_test a
connect by level <= length(a.name);
正确写法二
select level,
substr(a.name, level, 1) as jqhz,
substr(a.value, level, 1) as jqpy,
'substr('' '|| a.name ||' '',' || level || ',1)' jqgc
from table_test a
connect by level <= length(a.name);
错误写法一:
select level,
substr(a.name, level, 1) as jqhz,
substr(a.value, level, 1) as jqpy,
'substr(' ''|| a.name ||' '',' || level || ',1)' jqgc
from table_test a
connect by level <= length(a.name);
错误写法
正确写法: