pg.ddx.io pljava-dev@postgresql.org mailing list archive
help / color / mirror / Atom feedSubject: [Pljava-dev] advice needed
Date: Wed, 16 Feb 2005 08:41:02 +0100
Message-ID: <thhal-0k5HuAieGxicGsSqPOlnT0Ko33fqplf@mailblocks.com> (raw)
In-Reply-To: <249610-2200523161111193@M2W049.mail2web.com>
References: <249610-2200523161111193@M2W049.mail2web.com>
<4212F90E.5020005@mailblocks.com>
<thhal-0kpHuAiWGxicQQDTitru3P4skWO83pd@mailblocks.com>
info at wyse-systems.ltd.uk wrote:
>Hi,
>
>'quick' query to all of you gurus:
>
>I need to return a setof predefined complex type (similar to what a view
>does in 8.0) using pljava class, but found the pljava interface rather
>confusing:
>
>According to the docs I would need to implement assignRowValues to set the
>resulting columns for each row returned (defined by the 'currentRow' int
>parameter of this method). I found this rather inefficient - if I use a
>ResultSet within my class do I have to call rs.seek(currentRow) each time
>the assignRowValues method is called (i.e. rs.seek(2), then rs.seek(3) when
>the enxt call comes etc)?
>
>Am I missing something here?
>
>
Yes, you miss the whole point. The ResultSet is used because it exposes
a standard way of building a tuple. The assingRowValues builds one tuple
at a time and "returns" that tuple to the PostgreSQL backend. You do
not' need to do any positioning at all. The ResultSet that is used
contains exactly one row and it is positioned on that row.
Look at the examples in package org.postgersql.pljava.example
ComplexReturn.java
UsingProperties.java
>Also, in the jdbc sub-package there are quite a few SPI* methods which seem
>to mirror their counterparts from the SQL standard (or so was my
>impression).
>
>What is the purpose of these and how can I utilise them, am I better of
>using them instead of the 'standard' ones (I have absolutely *no* knowledge
>of PostgreSQL internals)? Is it better to use SPIConnection for e.g. rather
>than the 'normal' SQL Connection?
>
>
You should always use the standard interfaces. The SPI stuff is an
implementation of those interfaces. Never use the implementation
directly. If you do, you'll never be able to port your code to other
databases.
>The examples given in the examples.jar for complex types return in pljava
>are rather daft as they do not use sql result set at all (simple int
>addition and a timestamp) so I can't see how to utilise a ResultSet rows
>and return them one by one (if that is the idea of assignRowValues).
>
>
You could at least look at the code before you make statements like
that. ComplexReturn.java and UsingProperties.java both use assignRowValues.
>Appologiles for getting my hands on so many things - I just got into this
>(with Oracle is so much easier - you just type #sql select ?,?,? from
>my.table in java and off-you-go - it is all done without much hasle.
>
>
Your claim is based on SQLJ and Oracle is dropping its support for that.
You'll be reduced to using their Java interface directly. It is not
simpler then PLJava. IMHO, rather the opposite.
Regards,
Thomas Hallgren
view thread (12+ messages) latest in thread
Message-ID: <thhal-0k5HuAieGxicGsSqPOlnT0Ko33fqplf@mailblocks.com>
Permalink: ../thhal-0k5HuAieGxicGsSqPOlnT0Ko33fqplf@mailblocks.com/
Also on: postgresql.org/message-id/thhal-0k5HuAieGxicGsSqPOlnT0Ko33fqplf@mailblocks.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] advice needed
In-Reply-To: <thhal-0k5HuAieGxicGsSqPOlnT0Ko33fqplf@mailblocks.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