gpt4 book ai didi

java - 使用 Java 调用 PL/SQL 函数时参数的类型或数量错误。 PLS-00306 错误

转载 作者:行者123 更新时间:2023-12-01 10:07:19 25 4
gpt4 key购买 nike

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);
}
}

当我调用该函数时,显示 pls-00306 错误。每次它都会显示错误的类型或参数数量。请帮助我解决这些错误。变量值用于从组合框中获取输入。

最佳答案

您与内置函数发生冲突 LOG(n2,n1)返回n1对数,以n2为底。

使用其他名称。

关于java - 使用 Java 调用 PL/SQL 函数时参数的类型或数量错误。 PLS-00306 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36362261/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com