Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to concatenate two VARCHARs?

Hi all,

I would like to concatenate two variables (type VARCHAR) in HANA.

Unfortunately neither concat(:var1, :var2) nor var1 := :var1 || :var2 create the expected output.

Does anyone know why that doesn't work?

If I use a string instead of a second variable in the concat() function, everything works fine.

Thanks in advance and best regards,

Florian

Tags:
Former Member
replied

I tried with 3 terms and it works fine.. (please note in the code below, ' ' = single quote blank space single quote). I am not sure how to format the text font in this message.

CREATE PROCEDURE PR_TEST_02 (IN v_in_query varchar(100))

LANGUAGE SQLSCRIPT

AS

    v_val1   VARCHAR  (20);

    v_val2   VARCHAR  (20);

    v_val3   VARCHAR  (20);

    v_query  VARCHAR  (100);

BEGIN

  v_query := v_in_query;

  INSERT INTO tt_003 VALUES (:v_query);

  v_val1 := substr_before(:v_query, ' ');

  INSERT INTO tt_003 VALUES (:v_val1);

  v_query := substr_after(:v_query, ' ');

  INSERT INTO tt_003 VALUES (:v_query);

  v_val2 := substr_before(:v_query, ' ');

  INSERT INTO tt_003 VALUES (:v_val2);

  v_val3 := substr_after(:v_query, ' ');

  INSERT INTO tt_003 VALUES (:v_val3);

END;

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question