从字符串(VARCHAR2)oracle sql一一打印字符,而无需使用plsql,也无需使用double [英] Printing characters one by one from a string(VARCHAR2) oracle sql without using plsql and also without using dual

查看:74
本文介绍了从字符串(VARCHAR2)oracle sql一一打印字符,而无需使用plsql,也无需使用double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ORACLE 11g学习SQL.如何在ORACLE SQL中逐个字符地打印字符串(来自SELECT查询),而又不使用Dual和PLSQL?这是示例字符串:

I am learning SQL using ORACLE 11g. How to print a string(comes from a SELECT query), character by character in ORACLE SQL, without using dual and also without using PLSQL? Here is the sample string:

'MANOJ'

,输出应如下所示:

M

A

N

O

J

我尝试使用LEVEL,CONNECT BY,但它们在isqlplus中不起作用.请帮忙!

I tried using LEVEL,CONNECT BY but they are not working in isqlplus. Please help!

推荐答案

它是 SUBSTR 按级别连接的简单用法.看看如何将字符串分成行.

It is a simple use of SUBSTR and CONNECT BY LEVEL. Have a look at How to split string into rows.

例如,

SQL> SELECT SUBSTR('MANOJ', level, 1) str
  2  FROM dual
  3    CONNECT BY LEVEL <= LENGTH('MANOJ')
  4  /

S
-
M
A
N
O
J

SQL>

不确定不使用DUAL表"是什么意思,但是上面的双表仅用于创建示例数据进行演示.就您而言,可以使用列名而不是对值进行硬编码,并且如果您的值是子查询的结果,则可以使用子查询代替对偶表.

Not sure what you mean by "not using DUAL table", but the dual table above is just used to create the sample data for demonstration. In your case, you could use the column name instead of hard-coding the value, and you could use a sub-query in place of the dual table if your value is a result of a sub-query.

这篇关于从字符串(VARCHAR2)oracle sql一一打印字符,而无需使用plsql,也无需使用double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆