Like any programming language you can use a simple =+ to append to a variable string, but how do you do that within an Oracle PlSql block?
Example
my_string string
my_string = 'bla';
while ...(not greater than 10)
my_string += 'i';
expected output: bla12345678910
There are two ways to concatenate Strings in Oracle SQL . Either using CONCAT function or || operator. SELECT CONCAT( string1, string2 ) FROM dual; Since CONCAT function will only allow you to concatenate two values together.
The || Operator in PLSQL is used to concatenate 2 or more strings together. The result of concatenating two character strings is another character string.
Concatenation operator is ||
However, there is not short form of the concatenation that you are looking for (i.e. +=).
You can try this:
DECLARE
lvOutPut VARCHAR2(2000);
BEGIN
lvOutPut := 'BLA';
FOR i in 1..10 LOOP
lvOutPut := lvOutPut || i;
END LOOP;
DBMS_OUTPUT.PUT_LINE(lvOutPut);
END;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With