Re: How do I capture the message from user defined function

From: "etsuko shimabukuro" <etsukos(at)meta-bit(dot)com>
To: "Kris Jurka" <jurka(at)ejurka(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: How do I capture the message from user defined function
Date: 2003-02-03 07:49:32
Message-ID: PCEJINOPBBELPMMMEOJPEEAACBAA.etsukos@meta-bit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


Hi Kris,

Thank you for your advise.
Yes, it worked !
Sorry, I didn't println the warning message properly.

Appreciate your help very much.

Regards,
Etsuko
-----Original Message-----
From: jurka [mailto:jurka]On Behalf Of Kris Jurka
Sent: Monday, February 03, 2003 16:30
To: etsuko shimabukuro
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] How do I capture the message from user defined function

etsuko shimabukuro wrote:
>
> Dear Kris,
>
> Thank you for your email.
> I tried this getWarnings(), but it didn't capture the "notice" level of
the
> messages.
>
> Regards,
> Etsuko
>

The following code works for me on both 7.2.3 and 7.3.1 servers with the
latest jdbc driver. If you are running on the 7.3 series you should
also check the value of client_min_messages in postgresql.conf is set to
an appropriate value for you to receive notice messages.

Kris Jurka

import java.sql.*;

public class Raise {

public static void main(String args[]) throws Exception {
Class.forName("org.postgresql.Driver");
Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka","jurka"
,"");
Statement stmt = conn.createStatement();
stmt.executeUpdate("CREATE OR REPLACE function myraise() returns int
as 'BEGIN RAISE NOTICE ''Hello''; RETURN 0; END' LANGUAGE 'PLPGSQL'");
ResultSet rs = stmt.executeQuery("SELECT myraise()");
SQLWarning warning = conn.getWarnings();
System.out.println(warning);
}
}

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Vicente Alabau Gonzalvo 2003-02-03 08:01:03 Matching types
Previous Message Kris Jurka 2003-02-03 07:30:21 Re: How do I capture the message from user defined function