Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Oracle to VFP
Message
De
31/01/2001 20:16:30
 
 
À
31/01/2001 13:28:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00470801
Message ID:
00471047
Vues:
27
>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
Fil
Voir

Click here to load this message in the networking platform