this is my first pl/sql database project, so I am not experienced but need to start somewhere, I am writing a procedure for a update statement of customer table cpw which the user need to enter the username, if that match the cusername column the they will enter the old password, if that match with the cpw of the same row, then the system will update the new password which is prompt and accepted. here's what i have so far. any help will be appreciated.
CREATE OR replace PROCEDURE Changepassword (input_cusername IN VARCHAR,
old_cpw IN VARCHAR,
new_cpw OUT VARCHAR)
IS
DECLARE
c_username customer.cusername%TYPE;
c_cpw customer.cpw%TYPE;
BEGIN
ACCEPT input_cusername VARCHAR(40) prompt 'Username: '
ACCEPT old_cpw VARCHAR(20) prompt 'Enter Your Old Password:'
ACCEPT new_cpw VARCHAR(20) prompt 'Enter Your New Password:'
UPDATE customer
SET cpw = new_cpw
WHERE cusername = input_cusername;
EXCEPTION
WHEN input_cusername <> c_username customer.cusername%TYPE THEN
dbms_output.put_line('no such user exist');
WHEN old_cpw <> cpw FROM customer WHERE cusername = input_cusername THEN
dbms_output.put_line('Password Incorrect');
END;
There are many things wrong with your
procedure
.new_cpw
should be anIN
parameter.VARCHAR2
data type.DECLARE
your ownEXCEPTION
anduser-defined error
message usingraise_application_error
.validate
theUSERNAME
entered.RAISE
anEXCEPTION
forwrong_username EXCEPTION
.cusername entered is valid, i.e. if it exists in the table, then verify the
old password` entered is correct.exceptions
gracefully.password security
and levy somepassword rules
. For example,LENGTH
of password etc.