Allwolfpackfan
Programmer
Visual FoxPro/Oracle Question: I need to pull table data from an Oracle database into Visual FoxPro (Version 6.0). I need it to query based on 4 different fields but there are 2 fields it has problems with. Here is the code: Mserver, msuer, mpass, mconnect are all memory variables.
lnConn = SQLCONNECT((mserver), (muser), (mpass))
IF m.lnConn > 0 && Success.
WAIT "Connected" WINDOW NOWAIT
* Set the active database
SQLEXEC(m.lnConn, (mconnect))
* Execute SELECT statement.
SQLEXEC(m.lnConn, 'SELECT ARTCDPACK, COMPTS, MTLTS, MTLQTY, MTLTYPE, DAYNO, WEEKNO, YEARNO, STOCKID, PRODUNIT FROM WC20.VCPRMTL where MTLTYPE=01 AND YEARNO>=2018')
BROWSE
SQLDISCONNECT(m.lnConn)
ELSE
WAIT "Unable to connect to SQL Server" WINDOW
ENDIF
RETURN
=================================================================
The code above works perfectly but I need the Select Statement to include 2 more fields in the where clause. It needs to read like this:
SELECT ARTCDPACK, COMPTS, MTLTS, MTLQTY, MTLTYPE, DAYNO, WEEKNO, YEARNO, STOCKID, PRODUNIT FROM WC20.VCPRMTL where MTLTYPE=01 AND YEARNO>=2018 AND STOCKID=M AND PRODUNIT=M
But whenever I add STOCKID or PRODUNIT into the Select statement it returns no records. I cannot figure out why it works perfectly without those 2 but bombs out every time if I add either of those fields into the where clause. Any help would be greatly appreciated.
Tim
lnConn = SQLCONNECT((mserver), (muser), (mpass))
IF m.lnConn > 0 && Success.
WAIT "Connected" WINDOW NOWAIT
* Set the active database
SQLEXEC(m.lnConn, (mconnect))
* Execute SELECT statement.
SQLEXEC(m.lnConn, 'SELECT ARTCDPACK, COMPTS, MTLTS, MTLQTY, MTLTYPE, DAYNO, WEEKNO, YEARNO, STOCKID, PRODUNIT FROM WC20.VCPRMTL where MTLTYPE=01 AND YEARNO>=2018')
BROWSE
SQLDISCONNECT(m.lnConn)
ELSE
WAIT "Unable to connect to SQL Server" WINDOW
ENDIF
RETURN
=================================================================
The code above works perfectly but I need the Select Statement to include 2 more fields in the where clause. It needs to read like this:
SELECT ARTCDPACK, COMPTS, MTLTS, MTLQTY, MTLTYPE, DAYNO, WEEKNO, YEARNO, STOCKID, PRODUNIT FROM WC20.VCPRMTL where MTLTYPE=01 AND YEARNO>=2018 AND STOCKID=M AND PRODUNIT=M
But whenever I add STOCKID or PRODUNIT into the Select statement it returns no records. I cannot figure out why it works perfectly without those 2 but bombs out every time if I add either of those fields into the where clause. Any help would be greatly appreciated.
Tim