Reputation: 7906
Can i concat result value and then send the final value as output.
WHILE(LENGTH(totalexpenseamount )>0) DO
BEGIN
SET totalshipmentexpenseamount = CONCAT(totalshipmentexpenseamount,',',indshipmentexpenseamount);
END;
END WHILE;
but at end totalshipmentexpenseamount does not have any value in it.
Upvotes: 1
Views: 50
Reputation: 3905
don't know what is before the code that you presented, but you can try the following:
WHILE(LENGTH(totalexpenseamount )>0) DO
BEGIN
SET totalshipmentexpenseamount = CONCAT(COALESCE(totalshipmentexpenseamount, ''),',',indshipmentexpenseamount);
END;
END WHILE;
this is because totalshipmentexpenseamount
is set to null
in the first time and when you concat null
with other thing it comes out null
. The coalesce
will return empty if totalshipmentexpenseamount
is null
EDIT:
Change to this
WHILE(LENGTH(totalexpenseamount )>0) DO
BEGIN
SET totalshipmentexpenseamount = COALESCE(CONCAT(totalshipmentexpenseamount,',',indshipmentexpenseamount), indshipmentexpenseamount);
END;
WHILE;
Since you have concatenation with a comma, this will set in the first pass the value of indshipmentexpenseamount
otherwise will concat the totalshipmentexpenseamount
with a comma and the indshipmentexpenseamount
Upvotes: 1