sql 在MSS内移动单位

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 在MSS内移动单位相关的知识,希望对你有一定的参考价值。

/* 
* NAME: Unit_Move.sql
* AUTHOR: James R. Aylesworth
* DATE: 28-APR-14 @ 1335hrs
* DESCRIPTION: This script will move one unit over to another.
*
* The below example moves 485 to SAWGI
*/
--------------------------------------------------------------------------------
--// DECLARE SCRIPT VARIABLES //------------------------------------------------
--------------------------------------------------------------------------------
DEFINE oldUnit = '328';
DEFINE newDept = '500812';
DEFINE newUnit = '812';
DEFINE deptDesc = 'Neuro Medicine ICU-Nursing';
DEFINE currentEvalYear = '2013';
--------------------------------------------------------------------------------
--// UPDATE EMPLOYEE PROFILES //------------------------------------------------
--------------------------------------------------------------------------------
UPDATE EMPLOYEE_PROFILE
SET UNIT_ID='&newUnit', DEPT='&newDept'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// UPDATE UNITS GROUPS //-----------------------------------------------------
--------------------------------------------------------------------------------
UPDATE GROUPS
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// UPDATE UNITS SUB GROUPS //-------------------------------------------------
--------------------------------------------------------------------------------
UPDATE SUB_GROUP
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// UPDATE TIME CODES //-------------------------------------------------------
--------------------------------------------------------------------------------
UPDATE UNIT_TIMES
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// INSERT THE NP TIME CODES //------------------------------------------------
--------------------------------------------------------------------------------
UPDATE UNIT_NP_TIME
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// INSERT THE TIME BLOCK SPECS //---------------------------------------------
--------------------------------------------------------------------------------
UPDATE TIME_BLOCK_SPEC
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// INSERT THE UNIT SLOT LIMITS //---------------------------------------------
--------------------------------------------------------------------------------
UPDATE SLOT_LIMITS
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// INSERT EMPLOYEE FINALIZED STATUS FOR TIME BLOCK//--------------------------
--------------------------------------------------------------------------------
UPDATE FINALIZED
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// MOVE OVER ALL EMPLOYEE ENTERED TIMES FROM OLD UNIT TO NEW UNIT //----------
--------------------------------------------------------------------------------
UPDATE EMPLOYEE_TIMES 
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// UPDATE THE DEPT AND UNIT_ID IN THE UNIT_SPEC TABLE //----------------------
--------------------------------------------------------------------------------
UPDATE UNIT_SPEC
SET unit_id='&newUnit', DEPT='&newDept'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// UPDATE ALL INFORMATION FOR EVALS (eval unit, evaluator & sign-off) //------
--------------------------------------------------------------------------------
--UPDATE EMPLOYEE EVALUATOR IDS
UPDATE
  (
    SELECT * FROM employee_profile 
    WHERE unit_id='&newUnit' AND eval_id IS NOT NULL
  )
SET eval_id = '&newUnit'
  || '_'
  || SUBSTR(eval_id,5);
commit;

--UPDATE EMPLOYEE EVAL_ME IDS for 712
UPDATE
  (
    SELECT * FROM employee_profile
    WHERE unit_id='&newUnit' AND eval_me IS NOT NULL
    AND eval_me LIKE '%&oldUnit%'
  )
SET eval_me = '&newUnit'
  || '_'
  || SUBSTR(eval_me,5);
commit;

--UPDATE EMPLOYEE SIGN_OFF_ME IDS
UPDATE
  (
    SELECT * FROM employee_profile
    WHERE unit_id='&newUnit' AND sign_off_me IS NOT NULL
    AND sign_off_me LIKE '%&oldUnit%'
  )
SET sign_off_me = '&newUnit'
  || '_'
  || SUBSTR(sign_off_me,5);
commit;

--UPDATE THE EVAL_EMPL_PR table to new unit name
UPDATE EVAL_EMPL_PR
SET unit_id='&newUnit'
WHERE UNIT_ID='&oldUnit';
COMMIT;
--------------------------------------------------------------------------------
--// UPDATE UNIT_EVENTS TABLE //------------------------------------------------
--------------------------------------------------------------------------------
update unit_events
set unit_id='&newUnit'
where unit_id='&oldUnit';
commit;
--------------------------------------------------------------------------------
--// Update employee's preferance questions/answers //--------------------------
--------------------------------------------------------------------------------
UPDATE employee_prefs
SET unit_id  ='&newUnit'
WHERE UNIT_ID='&oldUnit';
commit;
--------------------------------------------------------------------------------
--// Update employee's extra shift requests //----------------------------------
--------------------------------------------------------------------------------
update OT_REQ
set unit_id='&newUnit'
where unit_id='&oldUnit';
commit;
--------------------------------------------------------------------------------
--// Update unit's  SLOT INFORMATION //-----------------------------------------
--------------------------------------------------------------------------------
update SLOTS
set unit_id='&newUnit'
where unit_id='&oldUnit';
commit;
--------------------------------------------------------------------------------
--// UPDATE EVAL UNIT NAME //---------------------------------------------------
--------------------------------------------------------------------------------
--only update the evaluations that haven't been printed(finished) yet
UPDATE eval_empl_pr
SET DEPT = '&deptDesc'
WHERE YEAR LIKE '&currentEvalYear%'
and unit_id='&newUnit'
AND (eval_status      <> 'Finalized'
OR EMPL_DS_STATUS NOT IN ('R','y','Y'));
--------------------------------------------------------------------------------
--// END UPDATE SCRIPT//--------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
/* OUTPUT FROM RUNNING SCRIPT
--------------------------------------------------------------------------------
PASTE_RESULTS_HERE
--------------------------------------------------------------------------------
*/

以上是关于sql 在MSS内移动单位的主要内容,如果未能解决你的问题,请参考以下文章

sql 在MSS中湮灭然后重建一个单元(HFM_SECT)。

sql 获取MSS和HRMS信息以验证数据

面试冲刺:54---MTU是什么?IP分片是什么?MSS是什么?TCP和UDP会分片吗?它们的关系是什么?

面试冲刺:54---MTU是什么?IP分片是什么?MSS是什么?TCP和UDP会分片吗?它们的关系是什么?

面试冲刺:54---MTU是什么?IP分片是什么?MSS是什么?TCP和UDP会分片吗?它们的关系是什么?

(转)MTU&MSS