我收到上述错误。 我试过让用户执行但没有运气。
这是我的SQL代码:
create or replace PACKAGE BODY reg_pack AS PROCEDURE ADDUSER( c_fname IN user_profile.firstname%type, c_lname IN user_profile.lastname%type, c_cnum IN user_profile.contactno%type, c_dob IN USER_PROFILE.DOB%type, c_address IN user_profile.address%type, c_city IN user_profile.city%type, c_state IN user_profile.state%type, c_country IN user_profile.country%type, c_email IN user_profile.emailid%type, c_password IN user_profile.password%type, c_usertype IN user_profile.usertype%type, c_username IN user_profile.username%type) IS BEGIN INSERT INTO USER_PROFILE (userid,firstname ,lastname,contactno,dob,address,city,state ,country,emailid,password,usertype,username) VALUES (userid_seq.NEXTVAL, c_fname, c_lname, c_cnum, c_dob, c_address, c_city, c_state, c_country, c_email, c_password, c_usertype, c_username); END ADDUSER;
PROCEDURE DELUSER(c_id IN user_profile.userid%type) IS BEGIN DELETE FROM USER_PROFILE WHERE user_profile.userid = c_id; END DELUSER;
PROCEDURE SELECTUSER(c_id IN user_profile.userid%type, c_fname OUT user_profile.firstname%type, c_lname OUT user_profile.lastname%type, c_cnum OUT user_profile.contactno%type, c_dob OUT USER_PROFILE.DOB%type, c_address OUT user_profile.address%type, c_city OUT user_profile.city%type, c_state OUT user_profile.state%type, c_country OUT user_profile.country%type, c_email OUT user_profile.emailid%type, c_password OUT user_profile.password%type, c_usertype OUT user_profile.usertype%type, c_username OUT user_profile.username%type) AS BEGIN
SELECT FIRSTNAME ,LASTNAME ,CONTACTNO ,DOB ,ADDRESS ,CITY ,STATE , COUNTRY ,EMAILID ,PASSWORD ,USERTYPE ,USERNAME INTO c_fname, c_lname, c_cnum, c_dob, c_address, c_city, c_state, c_country, c_email, c_password, c_usertype, c_username
FROM USER_PROFILE
WHERE user_profile.userid = c_id; END SELECTUSER;
END reg_pack;
如您所见,有三个程序,即DELUSER
,ADDUSER
和SELECTUSER
。我使用JDBC
执行这些查询,ADDUSER
查询有效,但其他两个返回PLS-00201
。
这是我的JAVA代码: 对于插入:
sql2 = "{call REG_PACK.ADDUSER(?,?,?,?,?,?,?,?,?,?,?,?)}";
callable = con.prepareCall(sql2);
callable.setString(1, fname);
callable.setString(2, lname);
callable.setString(3, cnum);
callable.setString(4, dob);
callable.setString(5, address);
callable.setString(6, city);
callable.setString(7, state);
callable.setString(8, country);
callable.setString(9, email);
callable.setString(10, password);
callable.setString(11, utype);
callable.setString(12, username);
callable.executeQuery();
删除:
int userID = Integer.parseInt(jTextField1.getText());
System.out.println(userID);
try{
String sqlDelete = "{CALL REG_PACK.DELUSER(?)}";
callable = con.prepareCall(sqlDelete);
callable.setInt(1, userID);
callable.executeQuery();
JOptionPane.showMessageDialog(this, "User deleted!");
}catch(SQLException e){
JOptionPane.showMessageDialog(this, e.getMessage());
}