TheLazyPig
Programmer
Hi!
I'm creating a form where tables used are from oracle.
The Select query suppose to run in oracle but I wanted to add it to my project so the user will extract it instead of me.
This is my code for OK button
I tried to run the form but it want to open a dbf file instead.
P.S I don't know why it want to open a table that's why I can't think of a proper name to my thread. Sorry
Thank you!
I'm creating a form where tables used are from oracle.
The Select query suppose to run in oracle but I wanted to add it to my project so the user will extract it instead of me.
This is my code for OK button
Code:
SET CENTURY OFF
SET CENTURY ON
SET DELETED ON
SET SAFETY OFF
SET UDFPARMS TO REFERENCE
CLOSE ALL
CLEAR
Public gnHandle, gnConnStr
LOCAL lcTrnsName, lcDir
SQLDisconnect(0)
**LIVE
lcTnsName = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.100)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ELIFE)))"
gnConnStr = "Driver={Microsoft ODBC for Oracle};Server="+ lcTnsName +";Uid=elifedba;Pwd=elifedba;"
gnHandle = SQLSTRINGCONNECT(gnConnStr)
lcDir = "'C:\RECOMPUTE\RECOMPUTE2\'"
lcMonth = ALLTRIM(THISFORM.cboMonth.VALUE)
lcMm = PADL(THISFORM.cboMonth.LISTINDEX, 2, "0")
lcYear = ALLTRIM(THISFORM.txtYear.VALUE)
FrDate = CTOD(lcMm+"/01/"+lcYear)
ToDate = GoMonth(FrDate,1)-1
dDate = LEFT(DTOS(FrDate),6)
LOCAL lcSQL
TEXT TO lcSQL TEXTMERGE NOSHOW
SELECT REPLACE(parsename(b.namestr,'LFM','LFM'),';','') AS PAYEE
,a.clntid
,trim(d.tin) AS TIN
,c.atc
,CASE reftype
WHEN 60007
THEN substr(fngetrefdesc(a.reftype),0,instr(fngetrefdesc(a.reftype),' -'))
WHEN 60002
THEN substr(fngetrefdesc(a.reftype),0,instr(fngetrefdesc(a.reftype),' -'))
WHEN 60006
THEN substr(fngetrefdesc(a.reftype),0,instr(fngetrefdesc(a.reftype),' -'))
END AS trantype
,CASE reftype
WHEN 60006
THEN (SELECT jvno FROM xac_jvmst WHERE jvseqno = a.refno)
ELSE a.refno
END AS reference
,a.currstatdate AS transaction_date
,a.baseamt
,c.rate AS percentage
,a.taxamt
,c.dsc AS description
,decode(a.reftype,60002,(SELECT purpose FROM xac_opmst WHERE opno = to_number(a.refno)),60006,(SELECT explanation FROM xac_jvmst WHERE jvseqno = to_number(a.refno)),NULL) AS particulars
FROM xac_taxes A
LEFT JOIN cnb_namelst_trn B
ON b.clntid = a.clntid
LEFT JOIN cxx_atcmst C
ON c.atcmst_seqno = a.atcdtl_seqno
LEFT JOIN cnb_clntmst D
ON d.clntid = a.clntid
WHERE 1=1
AND a.status = 60779
AND A.reftype IN (60002,60007,60006,72643)
AND A.currstatdate >= FrDate
AND A.currstatdate <= ToDate + 1 - INTERVAL '1' SECOND
AND c.atc IN ('WI 070','WI 071')
ORDER BY 1,2
ENDTEXT
IF MESSAGEBOX("Extract EWT for ["+lcMonth+" "+lcYear+"]?",36) = 6
COPY TO lcDir+"EWT_"+dDate TYPE XLS
MESSAGEBOX("File [EWT_"+dDate+".xls] Created!")
ELSE
MESSAGEBOX('Extraction Cancelled')
ENDIF
I tried to run the form but it want to open a dbf file instead.
P.S I don't know why it want to open a table that's why I can't think of a proper name to my thread. Sorry
Thank you!