>Hi All,
>
>I may have a requirement to convert/import data from an Oracle application into a VFP 6.0 app. Is there software in Oracle or VFP that will do that? Or is it best to convert the Oracle data to .txt and go from there? TIA.
>
>Regards,
>
>Paige
Paige,
There are many ways to do this. I use SQL pass thru commands to create a connection to an oracle table, send up a SELECT statement that saves to a local VFP table. I could have used ADO but SQL passthrough is much faster in my case. Here is what we did:
* turn off prompt for password
SQLSETPROP(0,"DispLogin",3)
lgCon = SQLCONNECT("SOME_ORACLE_DATA_SOURCE_NAME")
IF lgCon > 0
llOk = .T.
SQLSETPROP(lgCon,"Asynchronous",.T.)
ELSE
THIS.StoreErrorInfo("Connection Failed")
llOk = .F.
ENDIF
IF llOk
lcString = "SELECT * FROM SOME_ORACLE_TABLE SOME_ALIAS";
+" WHERE SOME_ALIAS.SOME_FIELD = '" + tcSomeValue + "'"
IF SQLPREPARE(lgCon,lcString,"VFP_CURSOR_NAME") = -1
THIS.StoreErrorInfo("Error compiling SQL statement")
llOk = .F.
ELSE
ltStart = DATETIME()
lnSec = DATETIME() - ltStart
lnTooMany = 900
* SINCE WE ARE USING Asynchronous MODE WE KEEP LOOPING
* AND CHECK TO SEE IF QUERY IS DONE, THIS ALSO ALLOWS
* YOU TO UPDATE PROGRESS TO THE USER IF NECESSARY
DO WHILE lnSec < lnTooMany
lnSQLRet = SQLEXEC(lgCon)
DO CASE
* success, done, get outta here
CASE lnSQLRet > 0
lnTooMany = 0
* still executing, wait and loop
CASE lnSQLRet = 0
INKEY(1,"h")
lnSec = DATETIME() - ltStart
* ERROR
CASE lnSQLRet = -1
THIS.StoreErrorInfo("Connection level error occured")
llOk = .F.
lnSec = lnTooMany
ENDCASE
ENDDO
IF lnTooMany = 900
llOk = .F.
THIS.cerrormsg = "Request timed out."
IF SQLCANCEL(lgCon) < 0
THIS.StoreErrorInfo("Error canceling query")
ENDIF
ENDIF
ENDIF
IF SQLDISCONNECT(lgCon) < 0
THIS.StoreErrorInfo("Error disconnecting")
llOk = .F.
ENDIF
ENDIF
PROCEDURE StoreErrorInfo
LPARAMETERS tcErrorMessage
THIS.lsqlerror = .T.
AERROR(THIS.aSQLError)
THIS.cerrormsg = tcErrorMessage;
+CHR(13)+THIS.aSQLError[2]+CHR(13)+THIS.aSQLError[3]
ENDPROC
HTH
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement