Write a stored procedure for later calls, the following is a manual written in the wrong place their own change to change;
write exhausted, but also added a note without points heaven tolerate feel tired, do not love
the Create Procedure publish_users IS or the replace
the Cursor c_record_players IS
* the Players from the SELECT;
v_cur c_record_players% ROWTYPE;
V_DB the Players% ROWTYPE;
the begin
- open the cursor result set
open c_record_players;
Loop
FETCH c_record_players
INTO v_cur;
Exit the when c_record_players% NOTFOUND;
- If you are just beginning users table is empty data is inserted
the begin
SELECT COUNT (*)
INTO v_record_num
from Users T
WHERE t.id = v_cur.id;
IF = 0 v_record_num the then
iNSERT INTO Users
(Ip,
username)
values
(v_cur.ipadress,
v_cur.playername
);
the else
- if users to facilitate future processing is not empty then the update data
Update users
SET = v_cur.ipadress IP,
username = v_cur.playername,
WHERE username = v_cur.playername;
End IF;
- the amount of data then submitted once every 5000
IF MOD (c_record_players% rowCount, 5000) = 0 the then
the commit;
End IF;
End Loop;
Close c_record_players;
End publish_users;
mysql database synchronization tables two data problem
Guess you like
Origin www.cnblogs.com/mynale/p/11018456.html
Recommended
Ranking