TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anjali Khan
NA
867
226.1k
How to store old value also in sql db using procedure
Mar 27 2017 7:00 AM
Hi Friends,
i have a status table where i am change the status and save in this data base.
step 1 - here if i change the status from the dropdown list then it is change and save in table
2 - again if i change the status then it is happening but i want in data base old value should be save this is also happening but again if i change status so all value showing same
my table structure and procedure like
NUMBER No STATUS_ID 1
VARCHAR2(255 BYTE) Yes STATUS 2
NUMBER Yes INCIDENT_ID 3
DATE Yes STATUS_DT 4
VARCHAR2(255 BYTE) Yes STATUS_OLD 5
create or replace PROCEDURE PROC_UPDATE_RECORD_STATUS
(
P_STATUS VARCHAR2,
P_USER_ID VARCHAR2,
--P_COMMENT_DESC VARCHAR2,
P_RECORDS OUT NUMBER
)
AS
v_sqlerrm varchar2(300);
v_dob date := NULL;
v_anniversaryDate date := NULL;
v_VERIFIED_BY VARCHAR2(100) := NULL;
v_VERIFIED_DATE timestamp := NULL;
BEGIN
COMMIT;
P_RECORDS:= 0;
--update
---
INSERT INTO APPL_RECORD_STATUS_HIST(USER_ID,STATUS,STATUS_DT)
select INCIDENT_ID,STATUS ,sysdate from APPL_RECORD_MST where USER_ID = P_USER_ID ;
UPDATE APPL_USER_MST
SET STATUS = P_STATUS
WHERE USER_ID = P_USER_ID ;
UPDATE APPL_USERT_STATUS_HIST
SET STATUS = P_STATUS, STATUS_OLD = STATUS where USER_ID = P_USER_ID;
P_RECORDS:= 1;
exception
when others then
v_sqlerrm:=substr(sqlerrm,1,300);
--rollback all if error.
Rollback;
Insert into APPL_ERR_LOG(ERROR_DATE,ERROR_MSG,ERROR_LOCATION)
values (sysdate, v_sqlerrm, 'PROC_UPDATE_USER_STATUS');
commit;
P_RECORDS:= 0;
END PROC_UPDATE_USER_STATUS;
MY TABLE DATA SHOULD BE LIKE THIS
STATUS_ID STATUS USER_ID STATUS_OLD
1 PROGRESS 10 PENDING
2 OPEN 10 PROGRESS
3 CLOSE 10 OPEN
BUT I AM GETTING LIKE
STATUS_ID STATUS USER_ID STATUS_OLD
1 PROGRESS 10 PENDING
2 PROGRESS 10 PENDING
3 PROGRESS 10 PENDING
note - here i have a dropdown list with change status and bind from the master db table it did this .
now if i changed status from to dropdownlist and save a in status table it is saved also .
now i want save to old value i used procedure it is workin g fine but if i changed 2nd or 3rd time it is changing but before which i changed also that valuse is changing
but i want if i changed status pending to open it is working then again open to progress n so on but here which status i changed like open to progress and before pending to open
all result showing same like open to progress all time
Reply
Answers (
4
)
How to set dynamic name in Row Header in ssrs report.
Access JSON data from Database Table to WPF datagrid