Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7D84C633852 for ; Fri, 9 Apr 2010 14:54:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 83322-07 for ; Fri, 9 Apr 2010 17:53:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.jfcomputer.com (unknown [76.14.161.106]) by mail.postgresql.org (Postfix) with ESMTP id 13971633EEF for ; Fri, 9 Apr 2010 14:53:52 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.jfcomputer.com (Postfix) with ESMTP id 084A67810D for ; Fri, 9 Apr 2010 10:53:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at jfcomputer.com Received: from mail.jfcomputer.com ([127.0.0.1]) by localhost (server1.jfcomputer.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G+4JBFOAl8LF for ; Fri, 9 Apr 2010 10:53:48 -0700 (PDT) Received: from [192.168.1.219] (unknown [192.168.1.219]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnf@mail.jfcomputer.com) by mail.jfcomputer.com (Postfix) with ESMTPSA id C943A76FF4 for ; Fri, 9 Apr 2010 10:53:48 -0700 (PDT) From: John To: pgsql-sql@postgresql.org Subject: Re: understanding select into Date: Fri, 9 Apr 2010 10:53:48 -0700 User-Agent: KMail/1.9.9 References: <201004091018.37965.johnf@jfcomputer.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201004091053.48604.johnf@jfcomputer.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.274 tagged_above=-10 required=5 tests=RDNS_NONE=1.274 X-Spam-Level: * X-Archive-Number: 201004/40 X-Sequence-Number: 33967 Wow thanks to all that replied - you folks are correct. The "_p" and the=20 others are vars. _p RECORD; I won't forget that one for a long time (however, I do drink :-)) Johnf On Friday 09 April 2010 10:32:51 am Pavel Stehule wrote: > Hello > > 2010/4/9 John : > > Hi, > > I am reviewing a function written by some xTuple guys. =C2=A0What is > > interesting about it is it uses the "INTO" statement like > > > > select something into _p from sometable where somecriteria. > > > > The function contiunes and uses the data retreived > > _p.somefield_name > > > > And then the function ends. > > > > > > Ok my question: > > > > I also thought the select "into" created a real table. =C2=A0But after = running > > the function the table does not exist. =C2=A0I see no where that a 'dro= p' is > > issued. In fact the function uses lot's of select into's like (_test, _= r, > > etc..). =C2=A0So would some kind soul explain what is happening. > > _p is record variable. See some lines before. There will be DECLARE part > > DECLARE p RECORD; > > There is plpgsql's SELECT INTO and SQL's SELECT INTO with little bit > different syntax. First - target is list of variables or record > variable, second - target is table. > > > Could it be that "_p" is drop automaticly when the function ends? > > =C2=A0Something to do with scope. > > _p is just variable > > regards > Pavel Stehule > > > Could it have something to do with the fact the function returns only an > > integer? =C2=A0And that causes the table to be drop. > > > > As you can see I'm lost here! > > > > > > Johnf