BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: yord ที่ มีนาคม 25, 2011, 15:41:38 PM

หัวข้อ: รบกวนผู้รู้ทั้งหลายครับ เรื่องรายงาน
เริ่มหัวข้อโดย: yord ที่ มีนาคม 25, 2011, 15:41:38 PM
เป็นรายงาน เอกสารติดตามผป.ครับ สั่งเรียกรายงานขึ้นมา ก็ out of memory ครับ
แต่ถ้าเปิดที่ report designer ก็ไม่ช้าครับ ไม่ทราบว่าต้องแก้ไขคำสั่งอย่างไรครับ ???
ขอบคุณครับ ;D ;D
hn := InputQuery('กรุณาใส่เลข HN', hn);

   if (hn = '')then
   repeat
   ShowMessage('กรุณาใส่เลข HN');
   hn := InputQuery('กรุณาใส่เลข HN', hn);
   until(hn <> '');

   ChangeReportSQL('select p.hn,concat(p.pname,p.fname,"  ",p.lname) as pt_name, '+
'p.cid,p.birthday,p.informname,p.informaddr,p.hometel, '+
'concat(p.addrpart," ม. ",p.moopart," ต. ",t3.name," อ. ",t2.name," จ. ",t1.name) as fulladdress '+
'from patient p '+
        'left outer join thaiaddress t1 on t1.chwpart=p.chwpart and '+
        't1.amppart="00" and t1.tmbpart="00" '+
        'left outer join thaiaddress t2 on t2.chwpart=p.chwpart and '+
        't2.amppart=p.amppart and t2.tmbpart="00" '+
        'left outer join thaiaddress t3 on t3.chwpart=p.chwpart and '+
        't3.amppart=p.amppart and t3.tmbpart=p.tmbpart '+
'where p.sex = "1" and p.hn in ('+hn+')  '+
'group by p.hn '+
'order by p.hn limit 1 ');
หัวข้อ: Re: รบกวนผู้รู้ทั้งหลายครับ เรื่องรายงาน
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ มีนาคม 25, 2011, 15:55:21 PM
until(hn <> '');  น่ากลัวสำหรับผม
หัวข้อ: Re: รบกวนผู้รู้ทั้งหลายครับ เรื่องรายงาน
เริ่มหัวข้อโดย: udomchok ที่ มีนาคม 25, 2011, 15:59:39 PM

hn := InputQuery('กรุณาใส่เลข HN', hn);

   if (hn = '')then
   repeat
   ShowMessage('กรุณาใส่เลข HN');
   hn := InputQuery('กรุณาใส่เลข HN', hn);
   until(hn <> '');

   ChangeReportSQL('select p.hn,concat(p.pname,p.fname,"  ",p.lname) as pt_name, '+
'p.cid,p.birthday,p.informname,p.informaddr,p.hometel, '+
'concat(p.addrpart," ม. ",p.moopart," ต. ",t3.name," อ. ",t2.name," จ. ",t1.name) as fulladdress '+
'from patient p '+
        'left outer join thaiaddress t1 on t1.chwpart=p.chwpart and '+
        't1.amppart="00" and t1.tmbpart="00" '+
        'left outer join thaiaddress t2 on t2.chwpart=p.chwpart and '+
        't2.amppart=p.amppart and t2.tmbpart="00" '+
        'left outer join thaiaddress t3 on t3.chwpart=p.chwpart and '+
        't3.amppart=p.amppart and t3.tmbpart=p.tmbpart '+
'where p.sex = "1" and p.hn in ('+hn+')  '+
'group by p.hn '+
'order by p.hn limit 1 ');
ตัดตรงสีแดงออกก็ได้นะครับ
แปลกใจตรงที่ต้อง group by และ order by แถม limit 1 อีก ใส่ทำไมครับ ในเมื่อ HN นี้รับค่ามาแค่ HN เดียว

หรือจะเปลี่ยนเป็น
   repeat
   ShowMessage('กรุณาใส่เลข HN ให้ถูกต้อง');
   hn := InputQuery('กรุณาใส่เลข HN', hn);
   until GetSQLStringData('select count(*) from patient where hn="'+hn+'" ') > 0;

ส่วนอื่น ๆ ยังไม่ได้ลอง run คำสั่ง เดี๋ยวดูก่อนนะครับ
หัวข้อ: Re: รบกวนผู้รู้ทั้งหลายครับ เรื่องรายงาน
เริ่มหัวข้อโดย: yord ที่ มีนาคม 25, 2011, 16:12:05 PM
ตรงที่ต้อง group by และ order by แถม limit 1 อีก
ผมลองน่ะครับ เผื่อจะทำให้เร็วขึ้น แต่..ก็เหมือนเดิม ครับ อิอิ ;D