Moeb
Moeb

Reputation: 10861

How to perform string concatenation in PL/SQL?

I have a variable defined as

define dbs '&1'

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

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?

Upvotes: 5

Views: 23494

Answers (1)

Thilo
Thilo

Reputation: 262504

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' || ''''

Upvotes: 18

Related Questions