Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using SQLEXEC() for a TSQL file...
Message
De
02/09/2002 07:14:37
 
 
À
02/09/2002 03:17:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00695487
Message ID:
00695902
Vues:
13
Hello,

here some snippet of source-code from the Article 'Managing SQL Server/MSDE from VFP - Part III' (published in FoxTalk Magazine October 2001)

i've slightly modified it to conform with the code in the previous post

* Use SPT to run the batch
* Because SPT can't run multiple batches separated
* with GO, breack up the statements using string
* manipulation
ln_conn = SQLCONNECT("DataSource")
lc_file = FILETOSTR("sql.txt")

lnBatches = OCCURS('GO' + CR ,UPPER(lc_file) )+ 1
    
  FOR lnBatch = 1 TO lnBatches
  
    * find the text between the current GOs
    lnFirstGo = IIF(lnBatch = 1, 1 - LEN('GO' + CR), ;
      AT('GO' + CR, UPPER(lc_file);
      , lnBatch - 1))
    lnLastGo = IIF(lnBatch = lnBatches, ;
      LEN(lc_file) + 1, AT('GO' + ;
      CR, UPPER(lc_file), lnBatch))
    lcSQL = SUBSTR(lc_file, ;
      lnFirstGo + LEN('GO' + CR), lnLastGo - ;
      lnFirstGo - LEN('GO' + CR))

    * run this batch
    lnResult = SQLExec(ln_conn, lcSQL)
    IF lnResult <> 1
      LOCAL laError[1]
      AERROR(laError)
      ** Display Error
      EXIT
    ENDIF

  ENDFOR
Regards

Christian
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform