首先,我這裏是病歷查詢的語句:
--[2016-03-18 15:22:11,406] Function Called in lngGetDataTableWithParameters
select dd.*,
p.lastname_vchr,
p.sex_chr,
p.birth_dat,
p.idcard_chr,
p.contactpersonphone_vchr,
f_getempnamebyid(dd.casedoctor_chr) casedoctorname,
bed_no sequenceno,
pt.paytypename_vchr,
pc.patientcardid_chr,
dept.deptname_vchr
from (select t.code_chr,
t.category_int,
t.extendid_vchr bedextendid_vchr,
t.sex_int,
t.status_int bedstatus_int,
t.rate_mny,
t.airrate_mny,
t.chargeitemid_chr,
t.nurseunitid_vchr,
d.registerid_chr,
d.bedid_chr,
d.type_int,
d.diagnose_vchr,
d.paytypeid_chr,
d.inpatientcount_int,
d.state_int,
d.pstatus_int,
d.casedoctor_chr,
d.deptid_chr,
d.areaid_chr,
d.nursing_class,
d.patientid_chr,
d.emrinpatientid,
d.emrinpatientdate,
d.hisinpatientid_chr,
d.hisinpatientdate,
d.casedoctorname,
t.bed_no
from (select re.registerid_chr,
re.bedid_chr,
re.type_int,
re.diagnose_vchr,
re.inpatientcount_int,
re.state_int,
re.pstatus_int,
re.casedoctor_chr,
re.deptid_chr,
re.paytypeid_chr,
re.areaid_chr,
re.nursing_class,
re.patientid_chr,
re.inpatientid_chr as emrinpatientid,
re.inpatient_dat as emrinpatientdate,
re.inpatientid_chr as hisinpatientid_chr,
re.inpatient_dat as hisinpatientdate,
f_getempnamebyid(re.casedoctor_chr) casedoctorname
from t_opr_bih_register_byemr3 re
where re.inpatient_dat between :1 and :2
and
re.status_int = 1
and re.pstatus_int not in (0, 3)
and not exists
(select re2.registerid_chr
from t_opr_bih_register_byemr3 re2
where re2.pstatus_int = 2
and re2.registerid_chr =
re.registerid_chr
and exists
(select re3.registerid_chr
from t_opr_bih_register_byemr3 re3
where re3.bedid_chr = re2.bedid_chr
and re3.pstatus_int not in
(0, 2, 3)
and re3.status_int = 1))) d
left outer join ( select bedid_chr,
areaid_chr,
code_chr,
status_int,
rate_mny,
sex_int,
category_int,
airrate_mny,
chargeitemid_chr,
airchargeflg_int,
airchargeitemid_chr,
extendid_vchr,
bihregisterid_chr,
creatorid_chr,
creat_dat,
cancelerid_chr,
cancel_dat,
bed_no,
nurseunitid_vchr
from t_bse_bed
where status_int <> 5) t on t.areaid_chr =
d.deptid_chr
and t.bedid_chr =
d.bedid_chr) dd
left join t_opr_bih_registerdetail p on dd.registerid_chr =
p.registerid_chr
left outer join t_bse_patientcard pc on pc.patientid_chr =
dd.patientid_chr
and (pc.status_int = 1 or
pc.status_int = 3)
left join t_bse_patientpaytype pt on dd.paytypeid_chr =
pt.paytypeid_chr
left join t_bse_deptdesc dept on dd.deptid_chr=dept.deptid_chr
order by bed_no;
--[2016-03-18 15:22:11,406] Values: 0: = 2016-3-18 0:00:00 ; 1: = 2016-3-18 23:59:59 ;
這裏有兩個時間值:
Values: 0: = 2016-3-18 0:00:00 ; 1: = 2016-3-18 23:59:59 ;
當我們在帶入值的時候,會提示格式不對:
這就需要我們在前面添加一個timestamp關鍵字來轉換格式。
就是將代碼中的
where re.inpatient_dat between :1 and :2
改成
where re.inpatient_dat between timestamp'2016-3-18 0:00:00' and timestamp'2016-3-18 23:59:59'
這樣就不會提示文字格式不匹配了