[英]Wrong type or number of parameters when calling a PL/SQL function using Java. PLS-00306 error
try{
Statement stmt = conn.createStatement();
stmt.execute("CREATE OR REPLACE FUNCTION log(p_user IN VARCHAR2, p_password IN VARCHAR2, p_name IN VARCHAR2 ) "
+ "RETURN number "
+ "IS "
+ "flag login%ROWTYPE; "
+ "temp number; "
+ "BEGIN "
+ "select username into flag "
+ "from login "
+ "where username=p_user and password=p_password and name=p_name; "
+ "IF (sql%found) THEN temp:= 1; "
+ "ELSE temp:= 0; "
+ "END IF; "
+ "return temp; "
+ "END; ");
stmt.close();
String value = Combo_Name.getSelectedItem().toString();
String sql= "begin "
+ "?:=log(?,?,?); "
+ "end; ";
CallableStatement cstmt = conn.prepareCall (sql);
cstmt.registerOutParameter (1, OracleTypes.NUMBER);
cstmt.setString(2, user_id.getText());
cstmt.setString (3, password.getText());
cstmt.setString(4, value);
cstmt.execute();
int check =cstmt.getInt(1);
if(check==1)
{
JOptionPane.showMessageDialog(null, "Login Successful");
}
else
{
JOptionPane.showMessageDialog(null, "Invalid Username or Password");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
A pls-00306
error is shown when I am calling the function. 调用函数时显示
pls-00306
错误。 Every time it shows wrong type or numbers of parameters. 每次显示错误的类型或参数数量。 Please help me to resolve the errors.
请帮助我解决错误。 The variable value is used to take input from the combo box.
变量值用于从组合框中获取输入。
You are clashing with a built-in function LOG(n2,n1)
that returns the logarithm , base n2
, of n1
. 您使用的是内置的功能冲突
LOG(n2,n1)
返回对数 ,基地n2
的, n1
。
Use another name. 使用其他名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.