From: c k <shreeseva.learning@gmail.com>
To: Richard Huxton <dev@archonet.com>
To: pgsql-general@postgresql.org
To: pgsql-admin@postgresql.org
Subject: Re: [GENERAL] Functions
Date: Mon, 15 Sep 2008 23:23:09 +0530
Message-ID: <d8e7a1e30809151053g5ce95e53m7621c017cd9adbe1@mail.gmail.com> (raw)
In-Reply-To: <d8e7a1e30809151052m50c3b006s87698bd517db13f5@mail.gmail.com>
References: <d8e7a1e30809150955v32f01897wa900261ac86af34b@mail.gmail.com>
<48CE9674.6020401@archonet.com>
<d8e7a1e30809151052m50c3b006s87698bd517db13f5@mail.gmail.com>
On Mon, Sep 15, 2008 at 11:22 PM, 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.)?
>
> CPK
>
> On Mon, Sep 15, 2008 at 10:38 PM, Richard Huxton <dev@archonet.com> wrote:
>
>> c k wrote:
>> > Dear PG members,I want to know that does begin and end in plpgsql are
>> > related to begin transactions and commit? if yes/no how?
>>
>> No. All functions operate within a transaction.
>>
>> > If I start to
>> > execute a function of multiple statements does PG commits each
>> transaction
>> > within a function, or whole function as a transaction.
>>
>> You can have many statements (function calls) within a single
>> transaction. If you don't explicitly issue BEGIN ... COMMIT then each
>> statement is wrapped in its own transaction. Note that some client
>> libraries have "autocommit" options that do things their own way.
>>
>> > Also if first statement makes inserts/updates a row, does it
>> automatically
>> > available to that particular function execution only or to any other
>> > instances of same function?
>> > Please give the details.
>>
>> If you insert/update/delete one or more rows, they are visible outside
>> the function - it's all the same tables.
>>
>> > In my system, function are extensively used and cab called by different
>> > clients as ODBC, JDBC and others.
>>
>> There is no difference between a user-written function and a built-in
>> function in PostgreSQL as regards calling them or their effects. Some
>> clients might offer better support than others, but they should all let
>> you build "raw" sql.
>>
>> --
>> Richard Huxton
>> Archonet Ltd
>>
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: shreeseva.learning@gmail.com, dev@archonet.com, pgsql-general@postgresql.org
Subject: Re: [GENERAL] Functions
In-Reply-To: <d8e7a1e30809151053g5ce95e53m7621c017cd9adbe1@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox