กรณีศึกษา ลบข้อมูลรายการยาไม่ได้ จากกลุ่ม HOSxP on facebook

More
6 ปี 10 เดือน ที่ผ่านมา - 6 ปี 10 เดือน ที่ผ่านมา #16 โดย admin
มีกรณีศึกษามาบอก

จากการที่มี รพ.เพื่อนๆ ที่ใช้ HOSxP แล้วลบข้อมูลรายการยาไม่ได้ จากการหาสาเหตุ เกิดจาก Trigger ในตาราง opitemrece (มีมาตั้งแต่เมื่อไหรก็ไม่รู้ ) ประเด็นคือ มันมีการเก็บ Delete log ไปไว้ที่ table temp_log แล้ว temp_log_id ผิดพลาด ถึงจะ Repair Serial ก็ไม่ได้ เพราะไม่อยู่ในระบบ ...

อันนี้ Script ของ Trigger ที่ ดักการ delete ข้อมูล

BEGIN DECLARE _count integer;

insert into temp_log (id,detail) values (get_serialnumber('temp_log_id'),concat('trg_opitemrece_delete : ',OLD.hos_guid)) ;

select count(*) into _count from stock_opitemrece_request where opi_guid = OLD.hos_guid ;

if _count>0 then insert into temp_log (id,detail) values (get_serialnumber('temp_log_id'),concat('trg_opitemrece_delete : ',OLD.hos_guid,' FOUND stock_opitemrece_request data removed')) ;

DELETE from stock_opitemrece_request where opi_guid = OLD.hos_guid ;

end if;

select count(*) into _count from opitemrece_stock_draw where opi_guid = OLD.hos_guid ;

if _count>0 then insert into temp_log (id,detail) values (get_serialnumber('temp_log_id'),concat('opitemrece_stock_draw : ',OLD.hos_guid,' FOUND stock_opitemrece_request data removed')) ;

DELETE from opitemrece_stock_draw where opi_guid = OLD.hos_guid ;

end if;

END



ตารางที่เกี่ยวข้อง Opitemrece -->ตารางที่มีการสร้าง Trigger ชื่อ trg_opitemrece_deleteSerial ---> เก็บ id ชื่อ temp_log_id


การแก้ไข

ใช้คำสั่ง Update serial set serial_no =(Select max(id) from temp_log) where name ='temp_log_id'

เพียงเท่านี้ก็สามารถทำให้ระบบรันไปได้แล้ว ....เฮ้อ เล่นเอาหลายวันเลย ...

*** แก้ไข
Update serial set serial_no =(Select max(id) from temp_log) where name ="temp_log_id"
แก้ไขล่าสุด: 6 ปี 10 เดือน ที่ผ่านมา โดย admin.

กรุณา เข้าสู่ระบบ หรือ สมัครสมาชิกใหม่ เพื่อเข้าร่วมวงสนทนา

เวลาที่ใช้ในการสร้างหน้าเว็บ: 0.166 วินาที
ขับเคลื่อนโดย ระบบฟอรัม Kunena