From: | johann at myrkraverk(dot)com (Johann 'Myrkraverk' Oskarsson) |
---|---|
To: | |
Subject: | [Pljava-dev] Returning complex complex objects |
Date: | 2010-12-15 15:42:40 |
Message-ID: | AANLkTinAyyJhuGy2qEhyt1vvj48R8buDhWiGVteMYZHb@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pljava-dev |
Hi Krzysztof,
On Mon, Dec 13, 2010 at 4:45 PM, Krzysztof <yazuna at gmail.com> wrote:
> Hello Johann,
> Certainly, the example of functionality is listed below - I was away
> from any Postgres console at the time of writing and I rather meant
> passing complex object to plJava, not getting from:
> <sql>
> -- nested, complex types handling...
>
> create type B as ( b_val float8,b2_val int)
> create type C as (c1_val float8, c2_val float8);
>
> -- create complex, nested type
> create type complexA as (
> ? ? ? ?b B,
> ? ? ? ?c C,
> ? ? ? ?a_val int)
Given the types above,
public static int complexParam( ResultSet receiver[] )
throws SQLException
{
for ( int i = 0; i < receiver.length; i++ )
{
ResultSet b = (ResultSet)receiver[ i ].getObject( 1 );
double b_val = b.getDouble( 1 );
int b2_val = b.getInt( 2 );
ResultSet c = (ResultSet)receiver[ i ].getObject( 2 );
double c1_val = c.getDouble( 1 );
double c2_val = c.getDouble( 2 );
int a = receiver[ i ].getInt( 3 );
;
}
return 0;
}
will handle the following select statement.
> select complexParam(array_agg(((0.1,i)::B,(0.1,10/i)::C,i)::complexA)) ?from
> generate_series (1,10) i;
However, you'll get quite a few lines of
WARNING: TupleDesc reference leak: TupleDesc 124e930 (139827,-1)
still referenced
Which I'll be working on soon.
If you run into convoluted examples where the the template above
doesn't get you started just ask again.
Johann
From | Date | Subject | |
---|---|---|---|
Next Message | Johann 'Myrkraverk' Oskarsson | 2010-12-15 16:09:01 | [Pljava-dev] Java VM stalls during |
Previous Message | Krzysztof | 2010-12-13 16:55:10 | [Pljava-dev] Pljava-dev Digest, Vol 78, Issue 9 |