Here is a full example of a java program showing the data from a set returning function:
------------------------- --IN YOUR DATABASE CREATE TABLE people (name TEXT); INSERT INTO people VALUES ('john'); INSERT INTO people VALUES ('peter'); INSERT INTO people VALUES ('joe'); CREATE FUNCTION getPeople() RETURNS SETOF people AS ' DECLARE rec RECORD; BEGIN FOR rec IN SELECT name FROM people LOOP RETURN NEXT rec; END LOOP; RETURN; END;' LANGUAGE 'plpgsql'; ------------------- --ListPeople.java import java.sql.*; public class ListPeople { public static void main(String[] args) { try { Class.forName("org.postgresql.Driver"); Connection con=DriverManager.getConnection("jdbc:postgresql:franco?user=admin"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("SELECT * FROM getPeople()"); while (rs.next()) { System.out.println(rs.getString("name")); } } catch (Exception e) { System.out.println("Exception: "+e.getMessage()); } } } On Friday 28 March 2003 19:31, Zodiac wrote: > Hello! > Can anybody tell me one thing. > How can i call stored procedures in my java-programm? > > Thanks for any help.
pgp00000.pgp
Description: signature