I have a test case which does the following in jdbc.
PreparedStatement cur_def_stmt = conn.prepareStatement("declare
registrar_c cursor for select name from epp_dummy where id = ?");
PreparedStatement cur_fetch_stmt = conn.prepareStatement
("fetch forward 1000 from registrar_c");
cur_def_stmt.setInt(1, 18);
cur_def_stmt.execute();
ResultSet resultSet = cur_fetch_stmt.executeQuery();
while(resultSet.next())
{
System.err.println(resultSet.getString(1));
}
conn.execSQLUpdate(";commit;");
On 7.4.x servers it errors out with
ERROR: no value found for parameter 1
Location: File: execQual.c, Routine: ExecEvalParam, Line: 518
Server SQLState: 42704
On 8.1.x servers it works fine ?
Here are the respective traces
7.4
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@57ea4a, maxRows=0, fetchSize=0, flags=23
FE=> Parse(stmt=null,query="begin",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Execute(portal=null,limit=1)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE CommandStatus(BEGIN)
<=BE ReadyForQuery(T)
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@568fb5, maxRows=0, fetchSize=0, flags=17
FE=> Parse(stmt=null,query="declare registrar_c cursor for select
name from epp_dummy where id = $1",oids={23})
FE=> Bind(stmt=null,portal=null,$1=<18>)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE NoData
<=BE CommandStatus(DECLARE CURSOR)
<=BE ReadyForQuery(T)
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@199939, maxRows=0, fetchSize=0, flags=17
FE=> Parse(stmt=null,query="fetch forward 1000 from
registrar_c",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE RowDescription(1)
8.1
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@4a7df6, maxRows=0, fetchSize=0, flags=23
FE=> Parse(stmt=null,query="begin",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Execute(portal=null,limit=1)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE CommandStatus(BEGIN)
<=BE ReadyForQuery(T)
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@2e323, maxRows=0, fetchSize=0, flags=17
FE=> Parse(stmt=null,query="declare registrar_c cursor for select
name from epp_dummy where id = $1",oids={23})
FE=> Bind(stmt=null,portal=null,$1=<18>)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE NoData
<=BE CommandStatus(DECLARE CURSOR)
<=BE ReadyForQuery(T)
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@221e9e, maxRows=0, fetchSize=0, flags=17
FE=> Parse(stmt=null,query="fetch forward 1000 from
registrar_c",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Describe(portal=null)
FE=> Execute(portal=null,limit=0)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE RowDescription(1)
<=BE DataRow
<=BE CommandStatus(FETCH)
<=BE ReadyForQuery(T)
simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement
$StatementResultHandler@701bdc, maxRows=0, fetchSize=0, flags=23
FE=> Parse(stmt=null,query="commit",oids={})
FE=> Bind(stmt=null,portal=null)
FE=> Execute(portal=null,limit=1)
FE=> Sync
<=BE ParseComplete [null]
<=BE BindComplete [null]
<=BE CommandStatus(COMMIT)
<=BE ReadyForQuery(I)
FE=> Terminate
I presume this is a bug in the 7.4 server, but need some clarification.
Dave