-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUPDATEQUERY.sql
More file actions
65 lines (37 loc) · 1.14 KB
/
UPDATEQUERY.sql
File metadata and controls
65 lines (37 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
create or replace procedure update_password(C_ID in number, pass in varchar2 )
IS
same_password_As_before exception;
CUST_PASSWORD varchar2(8);
Pass_length exception;
Begin
Select CUSTOMER_PASSWORD into CUST_PASSWORD from CUSTOMER_DETAILS where C_ID=customer_details.CUSTOMER_ID;
If(CUST_PASSWORD=pass)
then raise same_password_As_before;
elsif
length(pass)>8 then raise Pass_length;
else
update customer_details set CUSTOMER_PASSWORD=pass where customer_details.Customer_id=C_ID;
END IF;
Exception
When same_password_As_before then
RAISE_APPLICATION_ERROR(-20000, 'passwords cannot be same as before');
when Pass_length then
RAISE_APPLICATION_ERROR(-20001, 'passwords cannot be more than 8 alphanumeric characters');
END;
exec update_password(11489,'Knig133');
select * from customer_details;
------------------------
CREATE OR REPLACE PROCEDURE updateStock(
P_STOCK_ID IN STOCK_DETAILS.STOCK_ID%TYPE,
P_STOCK_NAME IN STOCK_DETAILS.STOCK_NAME%TYPE)
IS
BEGIN
UPDATE STOCK_DETAILS SET STOCK_NAME = P_STOCK_NAME where STOCK_ID = P_STOCK_ID;
COMMIT;
END;
/
BEGIN
updateStock('STOCK001','APPLEMAC');
END;
select * from stock_details;
COMMIT;