Thread: tab delimiter in output

tab delimiter in output

From
Marcin Krawczyk
Date:
Hi,

I need to return concatenated columns separated by tab character and I can't get it to work. Here's what I tried:

SELECT concat('aa', '\t', 'bb');
SELECT concat('aa', CHR(9), 'bb');
SELECT 'aa' || CHR(9) || 'bb';
SELECT 'aa' || '\t' || 'bb';

I get "aabb" instead of "aa       bb" in all cases. Is this a configuration issue ?


regards
mk

Re: tab delimiter in output

From
Ian Lawrence Barwick
Date:
2013/11/25 Marcin Krawczyk <jankes.mk@gmail.com>:
> Hi,
>
> I need to return concatenated columns separated by tab character and I can't
> get it to work. Here's what I tried:
>
> SELECT concat('aa', '\t', 'bb');
> SELECT concat('aa', CHR(9), 'bb');
> SELECT 'aa' || CHR(9) || 'bb';
> SELECT 'aa' || '\t' || 'bb';
>
> I get "aabb" instead of "aa       bb" in all cases. Is this a configuration
> issue ?

Try:

SELECT 'aa' || E'\t' || 'bb';

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE

Regards

Ian Barwick



Re: tab delimiter in output

From
Thomas Kellerer
Date:
Marcin Krawczyk, 25.11.2013 12:14:
> I need to return concatenated columns separated by tab character and I can't get it to work. Here's what I tried:
> 
> SELECT concat('aa', '\t', 'bb');
> SELECT concat('aa', CHR(9), 'bb');
> SELECT 'aa' || CHR(9) || 'bb';
> SELECT 'aa' || '\t' || 'bb';
> 
> I get "aabb" instead of "aa       bb" in all cases. Is this a configuration issue ?
> 

Which SQL tool do you use? 
Maybe your SQL client simply doesn't display the tab character? 







Re: tab delimiter in output

From
Marcin Krawczyk
Date:
Thanks, but it didn't change the output.


2013/11/25 Ian Lawrence Barwick <barwick@gmail.com>
2013/11/25 Marcin Krawczyk <jankes.mk@gmail.com>:
> Hi,
>
> I need to return concatenated columns separated by tab character and I can't
> get it to work. Here's what I tried:
>
> SELECT concat('aa', '\t', 'bb');
> SELECT concat('aa', CHR(9), 'bb');
> SELECT 'aa' || CHR(9) || 'bb';
> SELECT 'aa' || '\t' || 'bb';
>
> I get "aabb" instead of "aa       bb" in all cases. Is this a configuration
> issue ?

Try:

SELECT 'aa' || E'\t' || 'bb';

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE

Regards

Ian Barwick

Re: tab delimiter in output

From
Marcin Krawczyk
Date:
This might be the case. I'm using pgAdmin but I can't find anything in it's configuration.




2013/11/25 Thomas Kellerer <spam_eater@gmx.net>
Marcin Krawczyk, 25.11.2013 12:14:
> I need to return concatenated columns separated by tab character and I can't get it to work. Here's what I tried:
>
> SELECT concat('aa', '\t', 'bb');
> SELECT concat('aa', CHR(9), 'bb');
> SELECT 'aa' || CHR(9) || 'bb';
> SELECT 'aa' || '\t' || 'bb';
>
> I get "aabb" instead of "aa       bb" in all cases. Is this a configuration issue ?
>

Which SQL tool do you use?
Maybe your SQL client simply doesn't display the tab character?






--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Re: tab delimiter in output

From
seikath
Date:
hi Marcin,

try that for two tabs :
select concat('===[' , E'\t\t',']===');
select '===['|| E'\t\t'||']===';

cheers


On 11/25/2013 12:14 PM, Marcin Krawczyk wrote:
> Hi,
>
> I need to return concatenated columns separated by tab character and I can't get it to work. Here's what I tried:
>
> SELECT concat('aa', '\t', 'bb');
> SELECT concat('aa', CHR(9), 'bb');
> SELECT 'aa' || CHR(9) || 'bb';
> SELECT 'aa' || '\t' || 'bb';
>
> I get "aabb" instead of "aa       bb" in all cases. Is this a configuration issue ?
>
>
> regards
> mk