CARGAR UN PROCEDIMIENTO
Publicado por JOSE (1 intervención) el 25/03/2006 15:01:01
Hola, que tal...
Tengo un procedimiento almacenado en Oracle, si lo ejecuto desde SQL*PLUS me da el resultado siguiente:
429
30
13
363
Si lo llamo desde un servlet solo me regresa el último, es decir: 363
Lo mando llamar desde el servlet así:
try {
CallableStatement cs = conn.prepareCall("{ call EJEMPLO (?,?) }");
cs.setInt(1,2);
cs.registerOutParameter(2, java.sql.Types.INTEGER);
ResultSet r = cs.executeQuery();
while (r.next())
{
out.println("<br> ** "+ cs.getInt(2));
}
r.close();
}catch (Exception e) {
out.println("<br>" + "Hubo error en el procedimiento");
e.printStackTrace();
}
Mi procedimiento es el sigu:
CREATE OR REPLACE PROCEDURE "DICTAMINACION"."EJEMPLO" ( tipo in number,
res out number)
IS
cont number := 0;
cursor uno is select sum(cantidad) from dependencia where id_tipo = tipo group by substr(id_dependencia,1,3);
begin
OPEN uno;
loop
FETCH uno INTO cont;
EXIT WHEN uno%NOTFOUND OR uno%FOUND IS NULL;
res := cont;
dbms_output.put_line('CONT: ' || res);
end loop;
close uno;
end;
GRACIAS......
Tengo un procedimiento almacenado en Oracle, si lo ejecuto desde SQL*PLUS me da el resultado siguiente:
429
30
13
363
Si lo llamo desde un servlet solo me regresa el último, es decir: 363
Lo mando llamar desde el servlet así:
try {
CallableStatement cs = conn.prepareCall("{ call EJEMPLO (?,?) }");
cs.setInt(1,2);
cs.registerOutParameter(2, java.sql.Types.INTEGER);
ResultSet r = cs.executeQuery();
while (r.next())
{
out.println("<br> ** "+ cs.getInt(2));
}
r.close();
}catch (Exception e) {
out.println("<br>" + "Hubo error en el procedimiento");
e.printStackTrace();
}
Mi procedimiento es el sigu:
CREATE OR REPLACE PROCEDURE "DICTAMINACION"."EJEMPLO" ( tipo in number,
res out number)
IS
cont number := 0;
cursor uno is select sum(cantidad) from dependencia where id_tipo = tipo group by substr(id_dependencia,1,3);
begin
OPEN uno;
loop
FETCH uno INTO cont;
EXIT WHEN uno%NOTFOUND OR uno%FOUND IS NULL;
res := cont;
dbms_output.put_line('CONT: ' || res);
end loop;
close uno;
end;
GRACIAS......
Valora esta pregunta


0