我是Oracle的新手,并试图通过callStat从包中调用我的过程但是出现以下错误:
java.sql.SQLException: Paramètre IN ou OUT absent dans l'index :: 3
我读了很多关于这个问题的帖子,但是无法真正本地化我的问题,任何线索?
PROCEDURE get_employees(
emp_no IN number,
batch_size IN NUMBER,
found IN OUT NUMBER,
done_fetch OUT NUMBER,
emp_name OUT name,
emp_dept OUT dept,
emp_salary OUT sal) IS
BEGIN
IF NOT get_emp%ISOPEN THEN -- open the cursor if
OPEN get_emp(emp_no); -- not already open
END IF;
done_fetch := 0; -- set the done flag FALSE
found := 0;
FOR i IN 1..batch_size LOOP
FETCH get_emp INTO emp_name(i), emp_dept(i), emp_salary(i);
IF get_emp%NOTFOUND THEN -- if no row was found
CLOSE get_emp;
done_fetch := 1; -- indicate all done
EXIT;
ELSE
found := found + 1; -- count row
END IF;
END LOOP;
END;
public class main1 {
public static void main(String[] args) {
Connection conn = null;
CallableStatement cst = null;
ResultSet rs = null;
int emp_no = 100;
Object temp;
try {
Class.forName ("oracle.jdbc.OracleDriver");
conn =DriverManager.getConnection("yada yada yada");
conn.setAutoCommit(false);
System.out.println("Successfuly connected!");
cst = conn.prepareCall("{ call get_employees.pkg1(?,?,?,?) }");
cst.setInt(1, emp_no);
cst.registerOutParameter(2, OracleTypes.CURSOR);
cst.execute();
rs = (ResultSet) cst.getObject(2);
ResultSetMetaData rsm = rs.getMetaData();
int columnCount = rsm.getColumnCount();
while (rs.next()){
for (int j=0;j< columnCount;j++){
temp = rs.getObject(j+1);
}
}
答案 0 :(得分:1)
您尚未设置参数#3和#4。 你也可以为IN参数#2调用registerOutParameter。