[Pljava-dev] Custom java objects

From: makska at yandex(dot)ru (Maxim)
To:
Subject: [Pljava-dev] Custom java objects
Date: 2006-08-08 13:51:09
Message-ID: 12743.060808@yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hello,

I try to write aggregate function in Java for PostgeeSQL 8.1.

I just want to know, are there any ways to pass custom java objects
thorough iterations of row handler?

For example, I have functions in PostgreSQL (a is a table):

CREATE FUNCTION handler1(a, a)
returns a
as 'functions.handler1'
immutable language java;

CREATE FUNCTION handler2(a)
returns a
as 'functions.handler2'
immutable language java;

CREATE AGGREGATE aa ( BASETYPE = a, SFUNC = handler1, STYPE = a, FINALFUNC = handler2);

And two functions in Java:

public static boolean handler1(ResultSet a, ResultSet record, ResultSet result) throws Exception {
int v = a == null ? Integer.MIN_VALUE : a.getInt(1);
if (record.getInt(1) > v) {
result.updateInt(1, record.getInt(1));
result.updateString(2, record.getString(2));
} else {
result.updateInt(1, a.getInt(1));
result.updateString(2, a.getString(2));
}
return true;
}

public static boolean handler2(ResultSet a, ResultSet result) throws Exception {
if (a == null) return false;
result.updateInt(1, a.getInt(1));
result.updateString(2, a.getString(2));
return true;
}


I Just want to use custom java object instead of "ResultSet a".

--
Best regards,
Maxim Karavaev,
ISP RAS (www.ispras.ru)

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Burtenshaw, John J. 2006-08-08 17:13:06 [Pljava-dev] RMI from a trigger
Previous Message Peter Henderson 2006-08-08 11:28:56 [Pljava-dev] Class not found error