There are umpteen ways to skin a cat ...
The single quotes prevent the expansion of the shell variable - use double quotes instead. You could also write the script incl. the expanded variable to a file, and then have sed execute that.
For me, the best way would be to tell sqlplus NOT to break the lines but print the entire row output to one line.
The Following User Says Thank You to RudiC For This Useful Post: