varchar and spaces problem..

From: Fabrizio Mazzoni <veramente(at)libero(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: varchar and spaces problem..
Date: 2003-01-14 19:29:24
Message-ID: 20030114202924.63198631.veramente@libero.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all, first of all hello since i'm new to this list.

I have the following problem:

I created a table like this:

create table test(a varchar(10), b int)

If i insert the following data into the table :

insert into test values ('test ',2)

All the white spaces in the varchar string are inserted. Since the actual charachters in the string can vary, i cannot use char for the datatype.
I tried adding a rule that executes the following statement on insert:

create rule rl_testins as on insert to test do
update test set a=trim(trailing ' ' from a) where a=old.a

and it actually works. The problem is that on my production db i have tables that have 50-60 columns and i insert into these thousand of records in a short period of time and this slows down everything until it inserts only 1 record per second (without this rule it can insert ~100 records per second constantly).

Is there a workaround for this so pg can behave like ms access which truncates trailing spaces from varchar columns?

I cannot modifiy the sql statements because they are generated from a third party program which is written in cobol.

Thank you very much for any help provided and hope you have some answers since we are migrating from access to postgres...

Regards

Fabrizio Mazzoni
Macron Srl
http://eteampoint.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Barry Lind 2003-01-14 19:32:56 Re: [JDBC] JDBC isn't running
Previous Message Dennis Gearon 2003-01-14 19:24:52 'cgi-version' of pgsql