Usando el método EXECUTEREALSQL que ya definimos en otro post, es posible usar un método que lance un script de SQL como si de un TOAD se tratara.
Haremos lo siguiente:
- En un método (ambito cliente), primero abriremos un fichero de texto (scipt.sql) y, segundo, dejaremos el contenido en la variable MsScript:
MsFile = "C:\temp\script.sql"
OpenFile(MsFile,handle)
ReadFile(handle, chr(0), MsScript)
- Leeremos el fichero que separa las sentencias por ";" y las ejecutaremos usando el método EXECUTEREALSQL:
MsRest = MsScript
While length(MsRest )>0
MnSeparador = indexof(MsRest,";",0)
If MnSeparador <> M4_ERROR Then
MsToExec = Mid(MsRest ,0,MnSeparador )
MsRest = Mid(MsRest,MnSeparador + 1, length(MsRest)-MnSeparador -1)
EXECUTEREALSQL = MsToExec
MnRdo = EXECUTEREAL(0)
If MnRdo = M4_ERROR Then MessageBox("ERROR",MsToExec)
Else
EXECUTEREAL = MsScript + ";"
MnRdo = EXECUTEREALSQL (0)
If MnRdo = M4_ERROR Then MessageBox("ERROR",MsToExec)
EndIf
WEnd
Return M4_SUCCESS
Espero que os sirva
3 comentarios:
Hola..queria saber si hay una forma de ejecutar un script en el Sistema Operativo, una opcion parecida al ExecuteXXXX.
Gracias.
Javier, tengo una entrada en el blog que creo que responde a tu pregunta:
Ejecutable externo desde una regla de un método
Un saludo!
Oscar L.
Gracias Oscar, muy amable.
Publicar un comentario