how form below native sql query into session.createsqlquery()
SELECT STRMEDMAST.OU_CODE, SRC_PHACODE ,
STRMEDMAST.SRD_DATE,
STRMEDMAST.SR_NO,
STRMEDMAST.SRC_SLNO,
STRMEDMAST.SRC_REQUEST ,''ch, 'Y' typ,'N' print
FROM STRMEDMAST
where nvl( STRMEDMAST.SRC_CANCEL, 'N')='N' and
nvl(STRMEDMAST.SRC_CLOSE,'N')<>'Y'
and STRMEDMAST.src_reqto='P' and SRC_PHACODE = :r_code
and 'A'= :all_a
UNION ALL
SELECT PATDRGREQMST.ou_CODE,
patient.PT_NO,
PATDRGREQMST.DRD_DATE,
patient.PT_NO,
PATDRGREQMST.DR_SLNO,
patient.PTC_PTNAME,'','N',print
FROM PATDRGREQMST, patient
WHERE ( PATDRGREQMST.PT_NO = patient.PT_NO) and
( PATDRGREQMST.BMC_SLNO IS NULL) AND
PATDRGREQMST.DRC_CANCEL IS NULL AND NVL(PATDRGREQMST.IP_NO,'N')='N' AND
PATDRGREQMST.PH_CODE = :r_code
and 'O'= :op
UNION ALL
SELECT PATDRGREQMST.ou_CODE,
IPADMISS.PT_NO,
PATDRGREQMST.DRD_DATE,
IPADMISS.PT_NO,
PATDRGREQMST.DR_SLNO,
IPADMISS.PTC_PTNAME,'','N',print
FROM PATDRGREQMST, IPADMISS
WHERE ( PATDRGREQMST.IP_NO = IPADMISS.IP_NO) and
( PATDRGREQMST.BMC_SLNO IS NULL) AND
PATDRGREQMST.DRC_CANCEL IS NULL AND PATDRGREQMST.PH_CODE = :r_code
and 'I'= :ip
and ipadmiss.ipd_disc is null
order by 2
|