I am updating the PV1 segment with values from the database but when I get two values back I dont know how to separate them with a tilde and insert. Any advice for me on that?

so if I get two values returned

 

my PV1.7 segment should be :  

My current code is as below: It works fine for one value, but when there are more than 2 values returned I need to find a way to include it

00
0 5 82