开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜