[Pljava-dev] advice needed

From: thhal at mailblocks(dot)com (Thomas Hallgren)
To:
Subject: [Pljava-dev] advice needed
Date: 2005-02-16 07:41:02
Message-ID: thhal-0k5HuAieGxicGsSqPOlnT0Ko33fqplf@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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

In response to

Browse pljava-dev by date

  From Date Subject
Next Message Nageshwar Rao 2005-02-16 11:09:09 [Pljava-dev] inserting data from excel sheet
Previous Message info at wyse-systems.ltd.uk 2005-02-16 01:01:11 [Pljava-dev] advice needed