formatting into CSV format of SQL session output

I am getting a no of fields from a SQL session (e.g. select a,b,c from table). How do I convert the output values into CSV format .
The output should be like this 'a','b','c',

If the below one helps...!

echo "a,b,c" |sed "s/\(.\),*/'\1',/g"

Suppose the select query from the sql session is like that :

 
SQL > select a, b,c from table;

Now, if I am assigning this to a variable named VAR, then it will be like this :

VAR = a b c

My question was :

How do I for mat the above value into following :
'a','b','c',

If this is your input VAR="a b c" (there should be no space surrounding = when assigning to variables)then

echo $VAR| sed "s/\(.\) */'\1',/g" # note there is a space before *

If it is oracle then you can use concatenation operator ||

select ''''||a||''',' , ''''||b||''',' ''''||c||''',' from table;