Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Ivan Sergio Borgonovo" <mail(at)webthatworks(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding
Date: 2006-09-11 12:58:49
Message-ID: b42b73150609110558j9ef2a76tc6c6de7e4258bdfb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/11/06, Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> wrote:
> I'd write a trigger that generate a function.
> This is done for performance reasons.
> The function will be called several times and it is a list of delete statement according to the content of a table.
> The content of the table will seldom change and it is linked to the creation of other tables (metadata of other tables) and I want to provide a consistent interface to the downstream developers (if any in the future) and me.
>
> Since the code inside the function is getting a bit longer than what I was used I'm getting crazy about double quotes, syntax highlight and such.
> I'm using pg 7.4 so $$ trick shouldn't work.
>
> Do you have any advice about dynamically generated functions? Starting from a good vi/kate/whatever syntax highlighter to coding tricks to make the process less painful?

Although I wrote such functions for a while, I found them to be
unmaintanable. As soon as 8.0 came out, I converted everything I had
to dollar quoting as quickly as possible. Dollar quoting literally
transformed pl/pgsql into an amazing productive langauge. I strongly
advise you to consider this against whatever objections you have to
upgrading postgresql to a recent version.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tatsuo Ishii 2006-09-11 12:59:20 Re: [ANNOUNCE] == PostgreSQL Weekly News - September 10 2006 ==
Previous Message Ivan Sergio Borgonovo 2006-09-11 12:34:00 references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding