View Single Post

   
  #9 (permalink)  
Old 02-28-2008, 09:39 AM
Logos
 
Posts: n/a
Default Re: non-tab delimited output?

That does work, thank you

I chose VARCHAR over CHAR because of this excerpt from the MySQL online
dox:
"If a given value is stored into the CHAR(4) and VARCHAR(4) columns,
the values retrieved from the columns are not always the same because
trailing spaces are removed from CHAR columns upon retrieval."

So I chose VARCHAR, and then made sure the insertion cose space-pads
the field value up to the field length.


Michael Austin wrote:

> >>When I export, what I would like to see is
> >>
> >>1234567 456


>
> Since your data is already in varchar (does not space-fill) then you could use
> the ansi-standard CAST function.
>
> select cast(col1 as CHAR(20))||cast(col1 as CHAR(10))... from table1;
>
> again the || (double pipe) is ansi-standard concat syntax. I prefer to keep my
> sql and functions ansi-standard as you never know when you are going to need to
> port to a real database engine.
>
> the CHAR datatype should space-fill to the length specified. Last night I
> discovered on my platform (OpenVMS) that CHAR was not space-filing so a bug
> report was entered.
>
> the above should result in something like:
>
> select '~'||cast('ABC' as char(10))||'~';
>
> ~ABC ~
>
> select '~'||'ABC'||'~';
> ~ABC~
>
> [NOTE: the ~ is concatenated so you can see the "whitespace"]
>
> --
> Michael Austin.


Reply With Quote