X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 51CAD8BA057 for ; Sun, 13 Feb 2005 22:40:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38975-02 for ; Sun, 13 Feb 2005 22:40:23 +0000 (GMT) Received: from mail.airlinksystems.com (mail.airlinksystems.com [67.65.30.227]) by svr1.postgresql.org (Postfix) with ESMTP id 46FF68BA046 for ; Sun, 13 Feb 2005 22:40:20 +0000 (GMT) X-Envelope-To: pgsql-sql@postgresql.org Received: from mail.airlinksystems.com (localhost.localdomain [127.0.0.1]) by mail.airlinksystems.com (8.12.5/8.12.5) with ESMTP id j1DMhUkb008467; Sun, 13 Feb 2005 16:43:30 -0600 Received: (from apache@localhost) by mail.airlinksystems.com (8.12.5/8.12.5/Submit) id j1DMhTu0008465; Sun, 13 Feb 2005 16:43:29 -0600 X-Authentication-Warning: mail.airlinksystems.com: apache set sender to dgintz@airlinksystems.com using -f Received: from cs242710-104.austin.rr.com (cs242710-104.austin.rr.com [24.27.10.104]) by mail.airlinksystems.com (IMP) with HTTP for ; Sun, 13 Feb 2005 16:43:29 -0600 Message-ID: <1108334609.420fd81180f5e@mail.airlinksystems.com> Date: Sun, 13 Feb 2005 16:43:29 -0600 From: Richard Gintz To: Marc SCHAEFER Cc: pgsql-sql@postgresql.org Subject: Re: Order of columns in a table important in a stored procedure? References: <20050213170347.GA2658@defian.alphanet.ch> In-Reply-To: <20050213170347.GA2658@defian.alphanet.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.4 X-Originating-IP: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.006 tagged_above=0 required=5 tests=X_ORIG_IP_NOT_IPV4 X-Spam-Level: * X-Archive-Number: 200502/172 X-Sequence-Number: 20283 Pardon me ya'll, but can you tell me what a "saisies" is? Thanks, Dick -- Richard Gintz Airlink Systems 7600 Burnet Rd. Suite 515 Austin, TX 78757 PH: 512-231-1240 x108 FX: 512-231-9884 EM: dgintz@AirlinkSystems.com Quoting Marc SCHAEFER : > Hi, > > I use a FOR one_row IN loop where one_row is of type saisies%ROWTYPE. > The loop does a SELECT on a table, bennes, changing a few values. > > The idea is that the function should return some bennes rows, but > with additional information, which makes the returned rows > a saisies table-like row set. > > I have however noticed that if the SELECT is *NOT* in the correct order > for the table saisies, funny errors happen (such as type constraints -- > obviously columns are mixed). > > What I do not understand is that I use AS in order to name the columns, > I would think PostgreSQL could get the column names paired. > > This is annoying since it means that any change to the data structure, > such as adding columns may make my functions non working. > > This is however an old version of PSQL (7.1 I think). > > For reference: > > CREATE OR REPLACE FUNCTION f_fa_montre(VOID) > RETURNS SETOF saisies > AS ' > DECLARE > one_row saisies%ROWTYPE; > BEGIN > FOR one_row IN > SELECT NULL as idsaisie, > b.no_client AS num_client, > b.lieu_entreposage_b5 AS chantier, > DATE_TRUNC(\'month\', CURRENT_DATE) AS dates, > \'0\' AS num_bon, > NULL AS num_art > FROM bennes b > WHERE (type_fact_p = b.type_fact) > LOOP > -- here I do some changes to the one_row, BTW > RETURN NEXT one_row; > END LOOP; > > RETURN; > END;' > LANGUAGE 'plpgsql'; > > The issue: if I exchange num_bon and dates above the query fails. > > Thank you for any idea. > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.