ผู้เขียน หัวข้อ: ปิดกระทู้ครับผม  (อ่าน 1097 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ nu51313932nu

  • Newbie
  • *
  • กระทู้: 35
  • Respect: +1
    • ดูรายละเอียด
ปิดกระทู้ครับผม
« เมื่อ: เมษายน 10, 2017, 10:28:54 AM »
0
จากโค้ดนี้นะครับ  มี error คือมันบอกจำนวนคอลัมน์ไม่เท่ากัน   


คือต้องการให้
1.  1หน้ามียาสูงสุดแค่ 6 ตัว
2.   ถ้าหน้าสุดท้ายมีเศษ  คือไม่ครบ 6 ตัวให้ทำตารางเปล่าออกมาให้เต็ม


โค๊ด: [Select]
procedure GlobalOnCreate;

begin
      GetDateRangeDialog(date1, date2);
      ds1 := FormatDatetime('yyyy-mm-dd',date1);
      ds2 := FormatDatetime('yyyy-mm-dd',date2);
      an := GetUserParameter(0);
      hn := GetSQLStringData('select hn from ipt where an = "'+an+'"');
      count_record := GetSQLIntegerData('select count(op.icode) from opitemrece op '+
                      ' left outer join drugitems di on di.icode = op.icode'+
                      ' left outer join sp_use sp on op.sp_use = sp.sp_use'+
                      ' where an="'+an+'" and op.rxdate between "'+ds1+'" and  "'+ds2+'"'+
                       ' and NOT(op.drugusage = "" '+
                       ' and op.sp_use  = "")');

      {showmessage(IntToStr(count_record));}

      sql := 'select concat(di.name,"  ",di.strength),op.drugusage, op.sp_use'+
                       ' from opitemrece op '+
                       ' left outer join drugitems di on di.icode = op.icode'+
                      ' left outer join sp_use sp on op.sp_use = sp.sp_use'+
                      ' where an="'+an+'" and op.rxdate between "'+ds1+'" and  "'+ds2+'"'+
                        ' and NOT(op.drugusage = "" '+
                       ' and op.sp_use  = "")';
                     
                     
while count_record >= 6 do
         begin
                count_record :=   count_record-6;
         end;

         if count_record<>0 then
            newline := 6-count_record;


         while newline > 0 do
         begin
           sql := sql + ' union select "","'+IntToStr(newline) +'"'  ;
           newline := newline - 1;
         end;


      {showmessage(sql);}
      ChangeReportSQL(sql);
end;


« แก้ไขครั้งสุดท้าย: เมษายน 10, 2017, 11:12:45 AM โดย nu51313932nu »