agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feedSubject: [Pljava-dev] Calling pl/pgsql functions from pl/java?
Date: Thu, 20 Dec 2007 00:52:15 -0800
Message-ID: <C9C052B6-2121-49CF-AED6-58FB5BC84B08@mcsnw.com> (raw)
In-Reply-To: <B98BC88F-2AB2-4C65-90A9-35676AF4F1A9@mac.com>
References: <475DE7E2.3000506@mcsnw.com>
<141A53EE-DEE3-4C80-B4EF-F5A888F6F568@mac.com>
<475DF66A.4030400@mcsnw.com>
<B98BC88F-2AB2-4C65-90A9-35676AF4F1A9@mac.com>
I finally had time to go back and look at this, and it appears that
this is unique to PL/Java.
When Statement.execute(query) is called, the statement is not actually
executed by that command if it is a select query. This behavior is in
SPIStatement.executePlan... If isCursorPlan() returns true, a cursor
is opened for the query instead of executing it; nothing is done until
the resultset is acquired and *used*.
This works, it's just kind of kludgy, especially for functions that
don't actually return a useful value.
stmt.execute("SELECT mangle_user(5)"); // works with jdbc postgresql
driver
ResultSet res = stmt.getResultSet(); res.next(); res.close(); //
kludge to get calls to work with plpgsql
Perhaps this should be documented somewhere?
Thanks,
Lucas Madar
On Dec 10, 2007, at 7:01 PM, Jeffrey Lyon wrote:
> That's probably a question for the PostgreSQL guys, but it looks
> like the function isn't actually being called until the moment that
> the value is needed.
>
> J
>
> On Dec 10, 2007, at 9:31 PM, Lucas Madar wrote:
>
>> Oops. That was a stupid mistake in my dummy code. In the much more
>> complicated code, I've run into an interesting observation.
>>
>> If I call a function with select function(arg1, arg2) and then
>> ignore any returned result set, the function doesn't even get
>> executed.
>> If the function doesn't have a return (a null), there's nothing I
>> can do.
>>
>> If the function, however, returns something and I process its
>> resultset, the function is executed.
>>
view thread (5+ messages)
Message-ID: <C9C052B6-2121-49CF-AED6-58FB5BC84B08@mcsnw.com>
Permalink: ../C9C052B6-2121-49CF-AED6-58FB5BC84B08@mcsnw.com/
Also on: postgresql.org/message-id/C9C052B6-2121-49CF-AED6-58FB5BC84B08@mcsnw.com
reply
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: pljava-dev@postgresql.org
Subject: Re: [Pljava-dev] Calling pl/pgsql functions from pl/java?
In-Reply-To: <C9C052B6-2121-49CF-AED6-58FB5BC84B08@mcsnw.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox