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
224.5k
how to save old value with new value in sql pro _ its urgent
Mar 29 2017 7:49 AM
hi frnds
how to save old value with new value in oracle or sql procedure
1. User Table 2. User_Hist Table
a> 1st table i have fileds like user Id , city
b> 2nd table ID, User Id, city ,city_old
------------------------------------------
user Id city
101 Andhra-Pradesh
------------------------------------------
2nd table i want like
-----------------------------------------------------------------
ID User Id City City_Old
-----------------------------------------------------------------
1 101 MP Andhra-Pradesh
1 101 UP MP
1 101 Kernataka UP
BUT IF I CHANGE CITY ON 2ND TIME SO I GOT THE RECORD ON TABLE LIKE
---------------------------------------------------------------------------
ID User Id City City_Old
--------------------------------------------------------------------------------
1 101 MP Andhra-Pradesh
1 101 MP Andhra-Pradesh
1 101 MP Andhra-Pradesh
and my procedure is
create or replace PROCEDURE PROC_UPDATE_CITY
(
P_CITY VARCHAR2,
P_USER_ID VARCHAR2,
P_RECORDS OUT NUMBER
)
AS
BEGIN
COMMIT;
P_RECORDS:= 0;
INSERT INTO USER_HIST(USER_ID,CITY)
select USER_ID,CITY from USER where USER_ID = P_USER_ID ;
UPDATE USER
SET CITY = P_CITY
WHERE USER_ID = P_USER_ID ;
UPDATE USER_HIST
SET CITY = P_CITY CITY_OLD = CITY where USER_ID = P_USER_ID ;
P_RECORDS:= 1;
END PROC_UPDATE_CITY;
SO HOW TO GET RECORD LIKE
-----------------------------------------------------------------
ID User Id City City_Old
-----------------------------------------------------------------
1 101 MP Andhra-Pradesh
1 101 UP MP
1 101 Kernataka UP
AND WHERE I DID MISTAKE
Reply
Answers (
3
)
Access JSON data from Database Table to WPF datagrid
How to make auto generate column in database