Thread: Problem with Select output

Problem with Select output

From
srini vasan
Date:
Hi
   I am facing some issues with select query. The
values of the columns in one table contains "\n" as a
part of the value. So when I execute the select query
on this table, I am getting the following output.

# select * from stdhlr_subscriber_profile ;
subscriber_id | ssd_a
---------------+----------
470320000 | test
value
(1 row)

But the value of ssd_a is "test\nvalue". I want the
select output to print the value of ssd_a as
"test\nvalue".

Note:
   I have used COPY command to copy the value to a
file. In that file ssd_a is saved as "test\nvalue".
There is no newline substitution. I want to achieve
the same with select query.

I am using PSQl verison 7.2.2

Can you please suggest me how to do this?

Regards
Srini.



__________________________________
Do you Yahoo!?
All your favorites on one personal page � Try My Yahoo!
http://my.yahoo.com

Re: Problem with Select output

From
srini vasan
Date:
Hi all
   Can anybody please help me in this?

Regards
Srini

--- srini vasan <srinibalaji_82@yahoo.com> wrote:

> Hi
>    I am facing some issues with select query. The
> values of the columns in one table contains "\n" as
> a
> part of the value. So when I execute the select
> query
> on this table, I am getting the following output.
>
> # select * from stdhlr_subscriber_profile ;
> subscriber_id | ssd_a
> ---------------+----------
> 470320000 | test
> value
> (1 row)
>
> But the value of ssd_a is "test\nvalue". I want the
> select output to print the value of ssd_a as
> "test\nvalue".
>
> Note:
>    I have used COPY command to copy the value to a
> file. In that file ssd_a is saved as "test\nvalue".
> There is no newline substitution. I want to achieve
> the same with select query.
>
> I am using PSQl verison 7.2.2
>
> Can you please suggest me how to do this?
>
> Regards
> Srini.
>
>
>
> __________________________________
> Do you Yahoo!?
> All your favorites on one personal page � Try My
> Yahoo!
> http://my.yahoo.com
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
>     (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)
>




__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com

Re: Problem with Select output

From
Alvaro Herrera
Date:
On Wed, Dec 22, 2004 at 07:50:56AM -0800, srini vasan wrote:

Hi,

>    Can anybody please help me in this?

You could use the replace(text,text,text) function:

alvherre=# create table foo (a text);
CREATE TABLE
alvherre=# insert into foo values ('hola
alvherre'# ');
INSERT 155224 1
alvherre=# select * from foo;
   a
-------
 hola

(1 fila)

alvherre=# select replace(a, '\n', '\\n') from foo;
 replace
---------
 hola\n
(1 fila)

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"Para tener más hay que desear menos"

Re: Problem with Select output

From
Fernando Schapachnik
Date:
sleect function(ssd_a) from ...

where function is one of the built-in text function or one of your own written
in some of the supported (by your version) procedure languages.

Regards.

En un mensaje anterior, srini vasan escribió:
> --- srini vasan <srinibalaji_82@yahoo.com> wrote:
>
> > Hi
> >    I am facing some issues with select query. The
> > values of the columns in one table contains "\n" as
> > a
> > part of the value. So when I execute the select
> > query
> > on this table, I am getting the following output.
> >
> > # select * from stdhlr_subscriber_profile ;
> > subscriber_id | ssd_a
> > ---------------+----------
> > 470320000 | test
> > value
> > (1 row)
> >
> > But the value of ssd_a is "test\nvalue". I want the
> > select output to print the value of ssd_a as
> > "test\nvalue".