Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4D3BE37BF7A for ; Tue, 30 Sep 2008 21:54:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 87947-10 for ; Tue, 30 Sep 2008 21:54:11 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by postgresql.org (Postfix) with ESMTP id ED8CA37BCE2 for ; Tue, 30 Sep 2008 21:54:11 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id 16so225876fgg.23 for ; Tue, 30 Sep 2008 17:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=1nwTIMLUbGnUp3YkIRIojVaLiKgbO4jK41b8zX1az24=; b=hJMzi7/yKSDcsJn1UHcWzKmVG5BlqJo24IxG4XdS8a4TfELKsIpbpB0yY59iQtuUN0 tROPxlZOuit8urwMzCa4HqUXqlKaQUI0Ya2MjL9TxngHwZbyUY9d4PFkzLZ2Fncv6Lau 6IFTOfioub2/wivMBk/peul+d+nre36ibLXRI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=dhaCHpa63+KwE1WUdnx1c0BO9xWKLLeglNV7eRB3AExQnHGdd/sYF6zMauMeCAslwE gpBg4DTPorXKdkqeJFXJU13zANwp/O0LYORE0ZsG0rcI1hN9zh5AxIWmK/GOs3Mb/xN2 8zMNUbtRAlyxMJn8GEr661xYM/Jl7u1P8mbLE= Received: by 10.86.74.15 with SMTP id w15mr6380356fga.42.1222822449538; Tue, 30 Sep 2008 17:54:09 -0700 (PDT) Received: by 10.86.71.17 with HTTP; Tue, 30 Sep 2008 17:54:09 -0700 (PDT) Message-ID: <3a0028490809301754h46458028v27877bfa7a665ee6@mail.gmail.com> Date: Tue, 30 Sep 2008 22:54:09 -0200 From: "Rafael Domiciano" To: "Scott Marlowe" Subject: Re: [GENERAL] Functions Cc: "c k" , "Richard Huxton" , pgsql-general@postgresql.org, pgsql-admin@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_7010_12316381.1222822449534" References: <48CE9674.6020401@archonet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200809/361 X-Sequence-Number: 30454 ------=_Part_7010_12316381.1222822449534 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, If you want to get the value of a autogenerated column it's better to use "RETURNING" insert into something returning primary key... Best Regards, Rafael Domiciano Postgres DBA 2008/9/15 Scott Marlowe > On Mon, Sep 15, 2008 at 11:53 AM, c k > wrote: > > > > > > If I have a function having: > > begin > > insert into something ... > > select max(primary key) from something.. > > end; > > > > does the second statement within a function can view the results after > > execution of first statement to get max(P.K.)? > > Yep. > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > ------=_Part_7010_12316381.1222822449534 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hello,

If you want to get the value of a autogenerated column it's better to use "RETURNING"
insert into something returning primary key...

Best Regards,

Rafael Domiciano
Postgres DBA

2008/9/15 Scott Marlowe <scott.marlowe@gmail.com>
On Mon, Sep 15, 2008 at 11:53 AM, c k <shreeseva.learning@gmail.com> wrote:
>
>
> If I have a function having:
> begin
> insert into something ...
> select max(primary key) from something..
> end;
>
> does the second statement within a function can view the results after
> execution of first statement to get max(P.K.)?

Yep.

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

------=_Part_7010_12316381.1222822449534--