Re: Uppercase to lowercase trigger?

Lists: pgsql-general
From: Chrishelring <christianhelring(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Uppercase to lowercase trigger?
Date: 2012-05-02 12:33:23
Message-ID: 1335962003519-5680384.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

I´ve got some tables with column names in lowercase. Before updatering these
tables I want to add a trigger that can convert these lowercase to
uppercase, and when the tables are updates convert them back to lowercase..

I´ve looked at several examples without any luck. Could someone put me in
the direct direction?

Thanks

Christian

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Uppercase-to-lowercase-trigger-tp5680384.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-02 16:30:20
Message-ID: CAPTjJmqvsdMuaWnkbL5QtOofBfPY_tMSGcU2LKfmcvioXw_XyQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, May 2, 2012 at 10:33 PM, Chrishelring
<christianhelring(at)gmail(dot)com> wrote:
> Hi,
>
> I´ve got some tables with column names in lowercase. Before updatering these
> tables I want to add a trigger that can convert these lowercase to
> uppercase, and when the tables are updates convert them back to lowercase..

Not entirely sure what you're looking for here, but in Postgres, if
you don't quote your column names, they are lowercased by default.

UPDATE some_table SET ColumnName = 'foo', COLUMNNAME2 = 'bar';

This will work if the table has "columnname" and "columnname2".

ChrisA


From: Chrishelring <christianhelring(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-03 07:19:59
Message-ID: 1336029599677-5682473.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Maybe I should clarify what I mean.

I have a db (postgresql 8.4.1 with a postGIS spatial extension) with about
200+ tables in it. Some of them is supposed to be updated using an
application what requres that some of the columns are in uppercase (a
leftover from Oracle I suppose) but the main application that uses these
tables requres that the columns are in lowercase. I had an idea that using a
trigger I could chance the columns from lowercase to uppercase before
updating /changing the tables and after the update chance them back to
lowercase. Is that possible and how do I do that?

Christian

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Uppercase-to-lowercase-trigger-tp5680384p5682473.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Chrishelring <christianhelring(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-03 07:41:31
Message-ID: CAFj8pRBVjKkwJTiUFUKRpMarzOo5jDa0uVmcZ06KLOSL8=fpVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello

2012/5/3 Chrishelring <christianhelring(at)gmail(dot)com>:
> Maybe I should clarify what I mean.
>
> I have a db (postgresql 8.4.1 with a postGIS spatial extension) with about
> 200+ tables in it. Some of them is supposed to be updated using an
> application what requres that some of the columns are in uppercase (a
> leftover from Oracle I suppose) but the main application that uses these
> tables requres that the columns are in lowercase. I had an idea that using a
> trigger I could chance the columns from lowercase to uppercase before
> updating /changing the tables and after the update chance them back to
> lowercase. Is that possible and how do I do that?

no, this is not possible. But you can write simple functions that
verifies names and you can call this function manually when you do
some changes, or you can call this function from cron.

Regards

Pavel Stehule

>
> Christian
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/Uppercase-to-lowercase-trigger-tp5680384p5682473.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general


From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Chrishelring <christianhelring(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-03 07:50:07
Message-ID: CAD3a31WqQC0zKFjh_HzHrOUiNDBy3n_5s_-fAVeAJ-MMgeD5xw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

What if you created separate tables with the fields in uppercase, either
with different names or better yet the same names and a different schema?
It seems you could put triggers on those tables, and have your trigger
translate the field names and make the updates to the real tables instead.

Seems like a lot of work, though, that could be avoided if you could get
your app to drop the quoting of field names, and have it automatically fold
to lower case...

On Thu, May 3, 2012 at 12:41 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>wrote:

> Hello
>
> 2012/5/3 Chrishelring <christianhelring(at)gmail(dot)com>:
> > Maybe I should clarify what I mean.
> >
> > I have a db (postgresql 8.4.1 with a postGIS spatial extension) with
> about
> > 200+ tables in it. Some of them is supposed to be updated using an
> > application what requres that some of the columns are in uppercase (a
> > leftover from Oracle I suppose) but the main application that uses these
> > tables requres that the columns are in lowercase. I had an idea that
> using a
> > trigger I could chance the columns from lowercase to uppercase before
> > updating /changing the tables and after the update chance them back to
> > lowercase. Is that possible and how do I do that?
>
> no, this is not possible. But you can write simple functions that
> verifies names and you can call this function manually when you do
> some changes, or you can call this function from cron.
>
> Regards
>
> Pavel Stehule
>
>
> >
> > Christian
> >
> > --
> > View this message in context:
> http://postgresql.1045698.n5.nabble.com/Uppercase-to-lowercase-trigger-tp5680384p5682473.html
> > Sent from the PostgreSQL - general mailing list archive at Nabble.com.
> >
> > --
> > Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-general
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
AGENCY Software
A data system that puts you in control
*http://agency-software.org/*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801


From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-03 07:56:05
Message-ID: 4FA23A15.6060105@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 05/03/12 12:50 AM, Ken Tanzer wrote:
> What if you created separate tables with the fields in uppercase,
> either with different names or better yet the same names and a
> different schema? It seems you could put triggers on those tables,
> and have your trigger translate the field names and make the updates
> to the real tables instead.

if one of the applications is read only on this table, you could use a
view with the alternate version of the names.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast


From: Chrishelring <christianhelring(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-03 11:03:32
Message-ID: 1336043012069-5682880.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hmm.. Haden´t thought about making a view. It should work because the
application that uses the data is read-only (yet!).

I´ll give that a try. Thanks!

Christian

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Uppercase-to-lowercase-trigger-tp5680384p5682880.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Chrishelring <christianhelring(at)gmail(dot)com>
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-03 17:21:27
Message-ID: 4FA2BE97.9090109@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Chrishelring wrote:
> Hmm.. Haden´t thought about making a view. It should work because the
> application that uses the data is read-only (yet!).
>
> I´ll give that a try. Thanks!

Well a view is a much more natural solution than the other proposal, about
constantly doing data definition / changing the schemas for each access like
this proposal. In fact, what you talk about sounds like an ideal case for
views; you could have 2 complete schemas, one per application, where each
corresponds to the other but one is lowercase and one is uppercase, and one is a
view. -- Darren Duncan


From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-13 10:39:36
Message-ID: joo318$jef$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 2012-05-03, Chrishelring <christianhelring(at)gmail(dot)com> wrote:
> Maybe I should clarify what I mean.
>
> I have a db (postgresql 8.4.1 with a postGIS spatial extension) with about
> 200+ tables in it. Some of them is supposed to be updated using an
> application what requres that some of the columns are in uppercase (a
> leftover from Oracle I suppose) but the main application that uses these
> tables requres that the columns are in lowercase. I had an idea that using a
> trigger I could chance the columns from lowercase to uppercase before
> updating /changing the tables and after the update chance them back to
> lowercase. Is that possible and how do I do that?

No, you could try fashioning an updatable view in a different schema
and exploiting schema search path such the main application sees one
version and the legacy application sees the other.

this means writing a view to handle selects, and do instead rules for
updates and deletes.

shema search path can be defaulted on a per-user basis so if one of
the applications always uses a distincr username for the databse
connection this can be implemented in a way that's transparent

--
⚂⚃ 100% natural


From: björn lundin <b(dot)f(dot)lundin(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-15 06:04:47
Message-ID: 4362040.4665.1337061887660.JavaMail.geo-discussion-forums@vbym15
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hmm, I was under the impression that if you create the table with quoted field names, you get case-sensitive names,
But if you create the tables without quotes around the the field names, pg will make them lowercase,
But case-insensitive....

That way you don't need views or rewrite.

Do
create table foo( bar int);
Instead of
Create table
"foo" ("bar" int);

/björn lundin


From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Uppercase to lowercase trigger?
Date: 2012-05-15 07:57:00
Message-ID: CAPTjJmrUubX_q0HCXqM9UPrtRYF2MW4vMG8AS1OSKNB7Py_rnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Tue, May 15, 2012 at 4:04 PM, björn lundin <b(dot)f(dot)lundin(at)gmail(dot)com> wrote:
> Hmm, I was under the impression that if you create the table with quoted field names, you get case-sensitive names,
> But if you create the tables without quotes around the the field names, pg will make them lowercase,
> But case-insensitive....

If they're quoted, case is retained; if they're not, they're
lowercased. This rule applies to both creation and referencing, so if
you always leave them unquoted, they are effectively case insensitive
(technically they're case-folded), or if you always quote them,
they're case sensitive.

ChrisA