Обсуждение: PostgreSQL delete the blank in the end of the String automatically. how can I avoid it?

Поиск
Список
Период
Сортировка

PostgreSQL delete the blank in the end of the String automatically. how can I avoid it?

От
xier@in.tum.de
Дата:
hello,

my Name is Rong. I am student at TU-Munich. I have some questions for
Postgresql7.2  under SuSe Linux.
Postgresql7.2  under SuSe Linux8.0.
I use PostgreSQL7.2 with PGAdminII1.4.2 under Windows2000.

I insert a String from Teleform6.0 of Cardiff through ODBC in table of
PostgreSQL.
There should be some blank in the End of the String. e.g: "data
     "
But there ist no blank in the end of the String in the table. e.g: "data"
It means, that PostgreSQL delete the blank in the end of the String
automatically.
But I need the blank in the end of the String.
how can I avoid it?

How can convert TIFF Raw G3 to TIFF G4(image file format) in shell script
of linux.

I hope I can get your Help!
Thank you very much!

best regards!

rong








On 28/05/2004 13:04 xier@in.tum.de wrote:
> hello,
>
> my Name is Rong. I am student at TU-Munich. I have some questions for
> Postgresql7.2  under SuSe Linux.
> Postgresql7.2  under SuSe Linux8.0.
> I use PostgreSQL7.2 with PGAdminII1.4.2 under Windows2000.
>
> I insert a String from Teleform6.0 of Cardiff through ODBC in table of
> PostgreSQL.
> There should be some blank in the End of the String. e.g: "data
>      "
> But there ist no blank in the end of the String in the table. e.g: "data"
> It means, that PostgreSQL delete the blank in the end of the String
> automatically.
> But I need the blank in the end of the String.
> how can I avoid it?

AFAICT, it's not PostgreSQL which is causing your problem. I've just
tested against 7.2.1 using psql and it does _not_ remove trailing spaces.
I think your problem is with your client code.

HTH

BTW, 7.2 is very old. I'd recommend upgrading.

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for
Business             |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

Re: PostgreSQL delete the blank in the end of the String

От
xier@in.tum.de
Дата:
hi,

thank you very much for your tips!
As your tip: use a char() field instead of a varchar() field.
The problem is solved. Thanks!

have a good time!

rong

> xier@in.tum.de wrote:
>
>>hello,
>>
>>my Name is Rong. I am student at TU-Munich. I have some questions for
>>Postgresql7.2  under SuSe Linux.
>>Postgresql7.2  under SuSe Linux8.0.
>>I use PostgreSQL7.2 with PGAdminII1.4.2 under Windows2000.
>>
>>I insert a String from Teleform6.0 of Cardiff through ODBC in table of
>>PostgreSQL.
>>There should be some blank in the End of the String. e.g: "data
>>     "
>>But there ist no blank in the end of the String in the table. e.g: "data"
>>It means, that PostgreSQL delete the blank in the end of the String
>>automatically.
>>But I need the blank in the end of the String.
>>how can I avoid it?
>>
> If you know how long you need to field to be, use a char() field instead
> of a varchar() field or some other varying-length field.  If the length
> of the fields needs to be variable, then try putting some sort of
> termination character at the end of the blank space... such as a period
> (.), then have your program strip it out when it's reading it.
>
>>How can convert TIFF Raw G3 to TIFF G4(image file format) in shell script
>>of linux.
>>
> You can use a program called Image Magick for the image conversion.  The
> software has several programs that are installed as a result, and it's
> all usable via the shell.  The specific program that you'll want to read
> about is called "convert".  A program that I have set up that part of
> its function is to create thumbnail pictures uses convert like this:
>
> convert -geometry 221x164 sourcefile newfile
>
> Good luck!
>
>>
>>I hope I can get your Help!
>>Thank you very much!
>>
>>best regards!
>>
>>rong
>>
>>
> --
> Thanks,
> Laura Vance
> Systems Engineer
> Winfree Academy Charter Schools, Data-Business Office
> 1711 W. Irving Blvd. Ste 310
> Irving, Tx  75061
> Web: www.winfreeacademy.com
>
>



xier@in.tum.de writes:

> hello,
>
> my Name is Rong. I am student at TU-Munich. I have some questions for
> Postgresql7.2  under SuSe Linux.
> Postgresql7.2  under SuSe Linux8.0.
> I use PostgreSQL7.2 with PGAdminII1.4.2 under Windows2000.
>
> I insert a String from Teleform6.0 of Cardiff through ODBC in table of
> PostgreSQL.
> There should be some blank in the End of the String. e.g: "data
>      "
> But there ist no blank in the end of the String in the table. e.g: "data"
> It means, that PostgreSQL delete the blank in the end of the String
> automatically.
>
> But I need the blank in the end of the String.  how can I avoid it?

Let me guess, the offending column's type is char(x), right?. If
that's the case you must change it to something else, varchar or text.

Regards,
Manuel.

Re: PostgreSQL delete the blank in the end of the String automatically. how can I avoid it?

От
Jeff Eckermann
Дата:
--- Paul Thomas <paul@tmsl.demon.co.uk> wrote:
>
> On 28/05/2004 13:04 xier@in.tum.de wrote:
> > hello,
> >
> > my Name is Rong. I am student at TU-Munich. I have
> some questions for
> > Postgresql7.2  under SuSe Linux.
> > Postgresql7.2  under SuSe Linux8.0.
> > I use PostgreSQL7.2 with PGAdminII1.4.2 under
> Windows2000.
> >
> > I insert a String from Teleform6.0 of Cardiff
> through ODBC in table of
> > PostgreSQL.
> > There should be some blank in the End of the
> String. e.g: "data
> >      "
> > But there ist no blank in the end of the String in
> the table. e.g: "data"
> > It means, that PostgreSQL delete the blank in the
> end of the String
> > automatically.
> > But I need the blank in the end of the String.
> > how can I avoid it?
>
> AFAICT, it's not PostgreSQL which is causing your
> problem. I've just
> tested against 7.2.1 using psql and it does _not_
> remove trailing spaces.
> I think your problem is with your client code.

I had a thought that the ODBC driver could be
stripping the trailing spaces, but the test I just did
(using MS Access via ODBC) worked fine.

Thinking some more, I used a "text" type field for my
test.  I have some recollection that varchar(n) fields
_will_ strip trailing spaces.  But I'm too lazy to
test that right now.

>
> HTH
>
> BTW, 7.2 is very old. I'd recommend upgrading.
>
> --
> Paul Thomas
>
+------------------------------+---------------------------------------------+
> | Thomas Micro Systems Limited | Software Solutions
> for
> Business             |
> | Computer Consultants         |
> http://www.thomas-micro-systems-ltd.co.uk   |
>
+------------------------------+---------------------------------------------+
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org





__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

On 28/05/2004 20:46 Jeff Eckermann wrote:
> I had a thought that the ODBC driver could be
> stripping the trailing spaces, but the test I just did
> (using MS Access via ODBC) worked fine.

But that's using a different ODBC driver so won't show a possible bug in
the PG driver.

> Thinking some more, I used a "text" type field for my
> test.  I have some recollection that varchar(n) fields
> _will_ strip trailing spaces.  But I'm too lazy to
> test that right now.

I was testing using a varchar(n) field.

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for
Business             |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

Re: PostgreSQL delete the blank in the end of the String automatically. how can I avoid it?

От
Jeff Eckermann
Дата:
--- Paul Thomas <paul@tmsl.demon.co.uk> wrote:
>
> On 28/05/2004 20:46 Jeff Eckermann wrote:
> > I had a thought that the ODBC driver could be
> > stripping the trailing spaces, but the test I just
> did
> > (using MS Access via ODBC) worked fine.
>
> But that's using a different ODBC driver so won't
> show a possible bug in
> the PG driver.

PgAdminII uses the psqlodbc driver.  It's pgAdminIII
that does not.

>
> > Thinking some more, I used a "text" type field for
> my
> > test.  I have some recollection that varchar(n)
> fields
> > _will_ strip trailing spaces.  But I'm too lazy to
> > test that right now.
>
> I was testing using a varchar(n) field.

Which I just tested, and found to work fine.  My
recollection of the space-stripping behaviour of
varchar(n) appears to be off.

All of which is academic, seeing that the OP solved
his problem by using char(n).  But that leaves wide
open the question of why that would work, when
varchar(n) or text do not.

>
> --
> Paul Thomas
>
+------------------------------+---------------------------------------------+
> | Thomas Micro Systems Limited | Software Solutions
> for
> Business             |
> | Computer Consultants         |
> http://www.thomas-micro-systems-ltd.co.uk   |
>
+------------------------------+---------------------------------------------+
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the
> postmaster-------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster





__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/