Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with SQLExec () sequences
Message
De
16/11/2012 18:12:45
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01557240
Message ID:
01557492
Vues:
68
Thanks so much Borislav !

It really woks. Used your code, just added the message with progress, and the option to interrupt. Below is the complete code. Unfortunatelly it doesn't work with PostgreSQL.

Once again, thanks for your great support.. And to all other fellows that helped me in this problem. Thank you guys !
* ==============================================================================================
*                                    SQLPrepare ()
* ==============================================================================================

 SendMessage ("Prepairing to fetch records from remote source. Please wait...")

 cStartTime = Time ()

 gObjtSQLcommand = "Select * From " + IIf (Empty (cTable_Owner), "", cTable_Owner + ".") + cTable_Name
  
 SQLSetProp    (gSQLHandle, "Asynchronous", .F.)
 SQLSetProp    (gSQLHandle, "QueryTimeOut", 300)

 If SqlPrepare (gSQLHandle, gObjtSQLcommand, "CurSQLbrowse") <> 1
    ClearMessage ()
    aError  (SqlErrorTab)
    MessageBox ("SQL error (" + lTrim (Str (SqlErrorTab [1])) + ") issuing Select * From, procedure BrowseTableSQL." + Chr (13) + Chr (13) + ;
                              AllTrim (     SqlErrorTab [2]), (0+16+0), cCaption)
    Release  SqlErrorTab
    EnableMenus  ()
    Return
 endif
 
* ==============================================================================================
*                                    SQLExec () Loop
* ==============================================================================================

 ClearMessage ()

 nFetchSize      = 300
 nFetchedRecords =   0
 
 CursorSetProp ("FetchSize", nFetchSize   ,  0 )
 SQLSetProp    (gSQLHandle, "Asynchronous", .T.)

 Set Cursor     Off
 Set Status Bar On

 Set Message To " Prepairing to fetch records. Please wait..."

 Do While SQLExec (gSQLHandle) = 0

    nFetchedRecords = nFetchedRecords + nFetchSize
    nPercDone       = nFetchedRecords / nRecCount * 100

    If gSQLEngine <> "P"    && PostgreSQL
       Set Message To Space (1) + lTrim (Transform (nFetchedRecords, "999,999,999")) + " records already fetched (" + lTrim (Transform (nPercDone, "999")) + " %)" + "   Press <Esc> to interrupt"
       If InKey (.001) = 27
          If MessageBox ("Do you want to stop record fetching ?", (4+48+256), cCaption) = 7
             Loop  
          endif
          SQLSetProp (gSQLHandle, "Asynchronous", .F.)
          SqlCancel  (gSQLHandle)
          Exit
       endif
    else
       Set Message To Space (1) + lTrim (Transform (nFetchedRecords, "999,999,999")) + " records already fetched (" + lTrim (Transform (nPercDone, "999")) + " %)"
    endif

 EndDo

 Clear TypeAhead
   
 SQLSetProp    (gSQLHandle , "Asynchronous", .F.)
 CursorSetProp ("FetchSize",             -1,  0 )

 Set Cursor On
 Set Status Bar Off
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform