BMS-HOSxP Community

HOSxP => Delphi / Pascal => ข้อความที่เริ่มโดย: Knott ที่ มิถุนายน 01, 2022, 14:29:02 PM

หัวข้อ: sys_vn_pre_script สามารถมารถ update หรือ insert ข้อมูลลงตารางได้มั้ยครับ
เริ่มหัวข้อโดย: Knott ที่ มิถุนายน 01, 2022, 14:29:02 PM
อยากสอบถามครับ ใน sys_vn_pre_script สามารถเขียนคำสั่งให้อัพเดทข้อมูลในฐาน hosxp ได้มั้ยครับ
คือ มีค่าบางดัวอยากให้อัพเดทลงตารางทุกครั้งที่เปิดคนไข้ขึ้นมาเรียกซักประวัติน่ะครับ
ต้องใช้ function อะไร แล้วเขียนยังไงครับ ขอบคุณครับ
หัวข้อ: Re: sys_vn_pre_script สามารถมารถ update หรือ insert ข้อมูลลงตารางได้มั้ยครับ
เริ่มหัวข้อโดย: naj ที่ มิถุนายน 02, 2022, 15:47:48 PM
ทำได้ แต่อยู่ที่ว่าเราต้องการบันทึกค่าอะไรลงในตารางไหน
ตัวอย่าง Script
fcds3.data:=hosxp_getdataset('select vstdate,vsttime from ovst where vn="'+fvn+'"');
fcds3.open;
  if fdepcode<>'' then
  if fcds.recordcount=0 then
  begin
 fcds.insert;
  fcds['yindee_diy_id']:=getserialnumber('yindee_diy_id');
  fcds['vn']:=fvn;
  fcds['loginname']:=fcds2['kskloginname'] ;
  fcds['doctor']:= fdoctor;
  fcds['depcode']:=fdepcode;
  fcds['work_date']:=fcds3['vstdate'];
  fcds['work_time']:=fcds3['vsttime'];
  fcds['computer_name']:=fcds2['servername'] ;
  fcds['ip_computer']:= fcds2['computername'];
  end else
  begin
   fcds.edit;
  fcds['vn']:=fvn;
  fcds['loginname']:=fcds2['kskloginname'] ;
  fcds['doctor']:= fdoctor;
 fcds['depcode']:=fdepcode;
  fcds['edit_date']:=date;
  fcds['edit_time']:=time;
  fcds['computer_name']:=fcds2['servername'] ;
  fcds['ip_computer']:= fcds2['computername'];
  end;
  fcds.post;
    fcds.datarequest('select * from yindee_diy_workload where vn="'+fvn+'" and loginname="'+fcds2.fieldbyname('kskloginname').asstring+'" ');
  ApplyUpdate_fcds(-1);
  end;
หัวข้อ: Re: sys_vn_pre_script สามารถมารถ update หรือ insert ข้อมูลลงตารางได้มั้ยครับ
เริ่มหัวข้อโดย: BlueEye ที่ มิถุนายน 06, 2022, 11:49:41 AM
สามารถทำได้ครับ แต่ควรระมัดระวัง เพราะสคริปจะทำงานทุกครั้งที่ตรงกับเงื่อนไข ซึ่งอาจจะเกิดการ update หรือ insert มากเกินความจำเป็นครับ