Appending strings in Oracle within a plsql loop
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: bla12345开发者_StackOverflow678910
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;
精彩评论