如何在 PL/SQL 中执行字符串连接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3974875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 07:59:45  来源:igfitidea点击:

How to perform string concatenation in PL/SQL?

sqlstringplsqlconcatenation

提问by Moeb

I have a variable defined as

我有一个变量定义为

define dbs '&1'

Suppose I pass database1as an argument. Then the statement is interpreted as

假设我database1作为参数传递。然后该语句被解释为

define dbs database1

I want to append single quotes around the string, ie I want it to be interpreted as

我想在字符串周围附加单引号,即我希望它被解释为

define dbs 'database1'

How should I do this?

我该怎么做?

回答by Thilo

Single quotes in strings need to be escaped with another single quote, so you would write (if I understand macro expansion correctly)

字符串中的单引号需要用另一个单引号转义,所以你会写(如果我正确理解宏扩展)

 '''&1'''

String concatenation is done with the || operator

字符串连接是通过 || 完成的 操作员

 '''' || '&1' || ''''