Subject Please help - CallableStatement only returning first row of ResultSet
Author roddiwalker
Hi All, I'm new to FB and Jaybird so this could be a dumb question.
I created a test stored proc in the EMPLOYEE database (that comes with
FB) as:

SET TERM ^ ;

CREATE PROCEDURE FOO (
bar varchar(15))
returns (
c varchar(15))
as
begin

for select country from country where country >= :bar into :c do
begin
suspend;
end
end^
SET TERM ; ^
GRANT SELECT ON COUNTRY TO PROCEDURE FOO;
GRANT EXECUTE ON PROCEDURE FOO TO SYSDBA;

In IBExpert, "select * from foo('Germany')" returns USA, Switzerland,
Japan etc, as expected.

But if I run the following java code, I only get the first row (USA)

Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection conn =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:D:\\Programs\\Firebird\\examples\\empbuild\\employee.fdb",
"sysdba", "masterkey");
CallableStatement stmt = conn.prepareCall("{call foo(?)}");
stmt.setString(1, "Germany");
ResultSet rs = stmt.executeQuery();
while (rs.next())
System.out.println(rs.getString(1));
conn.close();

What am I doing wrong?
I am running FB 2.0.1, jaybird-full-2.1.1.jar, JDK 1.5.04 on Win XP Pro.

Strangely, using Statement rather than CallableStatement works fine:

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from foo('Germany')");
while (rs.next())
System.out.println(rs.getString(1));

Many thanks,
Roddi