existe algum comando pra forçar a gravação ?
Desde ja agradeço a ajuda.
*------------------------------------------------------------------------------*
Function QueryH( cSql, aParamSql,cDbf, cAlias, nConnection, lMens, lParser,lVetor )
*------------------------------------------------------------------------------*
Local aRetSql, hLine, aRetSqlH
Local cInstrucao, nAcao
Local nContLin, nContCol
Local c := 0
Local i := 0
Local cNew := ""
Local aVet := {}
Local nErr := 0
LOcal nPosErr := 0
Local oCon
Local nPos,oErr,cMsg
Local lConnectByQuery := .F.
Local aPcode
if lVetor = NIL
lVetor := .F.
Endif
if aParamSql = NIL
aParamSql:={}
Endif
if nConnection = NIL
nConnection := 0
Endif
If lMens = NIL
lMens := .t.
Endif
If lParser = NIL
lParser:= .F.
Endif
If cDbf == Nil
aVet := {}
Else
If cAlias == Nil
cAlias := cDbf
EndIf
EndIF
If Type( 'osql'+If( nConnection == 0, '', Str(nConnection,1) ) ) <> "O"
ConnectDataBase( nConnection )
lConnectByQuery := .T.
EndIf
If nConnection == 0
oCon := oSql
Else
oCon := &( "oSql"+Str(nConnection,1) )
EndIf
cInstrucao := Upper(SubStr(AllTrim(cSql),1,6))
&& Implementacao do Parse
If lParser
cSql := Sr_SqlCodeGen( Sr_SqlParse( cSql ), aParamSql )
Else
cSql := STRTRAN( cSql, "??", "?" )
For EACH c in cSql
if c == "?"
cNew += SR_cDBValue( aParamSql[++i] )
Else
cNew += c
EndIf
Next
cSql := cNew
EndIf
Do Case
Case cInstrucao = "DELETE"
nAcao := 1
Case cInstrucao = "UPDATE"
nAcao := 2
Case cInstrucao = "INSERT"
nAcao := 3
Case cInstrucao = "CREATE"
nAcao := 4
Otherwise
nAcao := 0
EndCase
&& Retornar um arrey multidimensional
If lVetor
aVet := {}
If nConnection == 0
oCon := oSql
Else
oCon := &( "oSql"+Str(nConnection,1) )
EndIf
Try
oCon:Exec( cSql, .t., .t., @aVet, cDbf, cAlias )
Catch oErr
Err := oErr
lErroRepoe := .t.
msgstop(Err)
&& Menssagem de erro
END
Return aVet
Endif
&& Dbf Virtual
If cDbf != Nil
aVet := {}
If nConnection == 0
oCon := oSql
Else
oCon := &( "oSql"+Str(nConnection,1) )
EndIf
Try
oCon:Exec( cSql, .t., .t., @aVet, cDbf, cAlias )
Catch oErr
Err := oErr
lErroRepoe := .t.
msgstop(Err)
&& Menssagem de erro
END
Return aVet
Endif
aRetSql := {}
aRetSqlH := {}
Try
Do Case
Case nAcao = 1 && DELETE
oCon:Exec( cSql , .t. , .F. )
Case nAcao = 2 && UPDATE
oCon:Exec( cSql , .t. , .F. )
Case nAcao = 3 && INSERT
oCon:Exec( cSql , .t. , .F. )
Case nAcao = 4 && CREATE
oCon:Exec( cSql , .t. , .F. )
Otherwise && SELECT
oCon:Exec( cSql , .t. , .t. , @aRetSql )
For nContLin := 1 to Len(aRetSql)
hLine := Hash()
For nContCol := 1 to Len(oCon:aFields)
hSet( hLine , Upper( AllTrim( oCon:aFields[nContCol,1] ) ) , aRetSql[nContLin,nContCol] )
Next
hSetCaseMatch( hLine , .F. )
aAdd( aRetSqlH , hLine )
Next
EndCase
Catch oErr
Err := oErr
lErroRepoe := .t.
msgstop(Err)
&& Menssagem de erro
END
Return aRetSqlH