Re: Removing spaces

From: Fabrizio Mazzoni <veramente(at)libero(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Removing spaces
Date: 2003-02-20 19:42:44
Message-ID: 20030220194244.7cede80e.veramente@libero.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You could use the trim function in a plpgsql trigger function eg:

CREATE FUNCTION fn_tr_longpad() RETURNS trigger AS '
begin
NEW.a := trim(trailing '' '' from NEW.a);
return NEW;
end; ' LANGUAGE 'plpgsql';

CREATE TRIGGER tst_trigger BEFORE INSERT ON mytable FOR EACH ROW EXECUTE PROCEDURE fn_tr_longpad()

a is the name of the column you have to trim, change it to your needs

Regards,

Fabrizio Mazzoni

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dan Delaney 2003-02-20 19:50:18 Re: Dealing with schema in psql utility?
Previous Message Richard Huxton 2003-02-20 19:29:19 Re: What is the quickest query in the database?