Re: Java app and SPI functions

From: Adriaan Joubert <a(dot)joubert(at)albourne(dot)com>
To: Katsaros Kwn/nos <ntinos(at)aueb(dot)gr>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Java app and SPI functions
Date: 2004-09-30 13:28:20
Message-ID: 415C09F4.2090506@albourne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Ntinos,

You don't need to use PL/Java - you can call the SPI functions
through standard SQL. I have C functions that return tuples and call
them with executeQuery(...).

The function in question is defined as

CREATE TYPE correlation_type AS
(
id INTEGER,
num_points INTEGER,
correlation FLOAT8
);

CREATE OR REPLACE FUNCTION
max_min_correlation(int,smallint,smallint,int,int)
RETURNS SETOF correlation_type
AS '$libdir/contrib/my_func.so','max_min_correlation'
LANGUAGE 'C' STABLE STRICT;

and then I call it with

ResultSet results = st
.executeQuery("SELECT * FROM
max_min_correlation("+var+")");

and work through the result set.

Good luck,

Adriaan

Katsaros Kwn/nos wrote:

>Hi everybody!
>
>I'm new to PostgreSQL with JDBC. What I want to do is to connect an
>already implemented Java application to my postgresql server.I want to
>be able to pass arguments from the java application to some function
>I've written in C (that uses SPI functions) and receive tuples to
>display in the Java GUI.
>
>Any hints on where to start from?
>
>Richard Huxton at the General list kindly pointed me to the PL/Java
>project. Is this where I should focus?
>
>Thanks in advance,
>Ntinos Katsaros
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
>

Attachment Content-Type Size
a.joubert.vcf text/x-vcard 288 bytes

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-09-30 21:55:14 Re: Remote query very slow
Previous Message Katsaros Kwn/nos 2004-09-30 12:16:44 Java app and SPI functions