Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9071C632D72 for ; Fri, 28 May 2010 17:46:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 62322-10 for ; Fri, 28 May 2010 20:46:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by mail.postgresql.org (Postfix) with ESMTP id 15C1D632CAD for ; Fri, 28 May 2010 17:46:10 -0300 (ADT) Received: from [157.92.152.105] (unknown [157.92.152.105]) by mail.fmed.uba.ar (Postfix) with ESMTP id B6B9A48B992; Fri, 28 May 2010 16:44:31 -0300 (ART) Message-ID: <4C00241B.3020604@fmed.uba.ar> Date: Fri, 28 May 2010 17:14:19 -0300 From: Gerardo Herzig User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: Jasen Betts CC: pgsql-sql@postgresql.org Subject: Re: cast record type to array? References: <4BFD9A6C.1060203@fmed.uba.ar> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/140 X-Sequence-Number: 34188 Jasen Betts wrote: > On 2010-05-26, Gerardo Herzig wrote: >> Hi all. Im not being able to cast a record variable into an array. >> >> Im writing a trigger, and i would like to store NEW (and OLD) as text[]. >> There is a way to do it in plpgsql? (w/o any contrib modules) > > why not store them as text instead? > > new::text > > is a valid cast. > > Hi Jasen. Storing the record in text format will difficult furter analisis (p.e.searching columns with differences between OLD and NEW). It will not be easy to play with NEW as string for obtaining each column values (string_to_array will not work, the values for NEW can be anything) As this trigger will save information for audit, it is important to get it right. Even worst, im *strongly encouraged* not to use any other language except plpgsql, so i cant use plpythonu, in wich will be trivial to do so. thanks for your time, Jasen Gerardo