16

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

1 Answer 1

30

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;
Sign up to request clarification or add additional context in comments.

1 Comment

Ah thanks. Sometimes I just assume =+ is a default within any program language. Was going to use the long hand method of that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.