Error: 102 run query via MsExecAuto

I have little experience in advpl. I was studying the subject and I have a little problem. I get the erro 102 when I try to include a registration in the table customers direct in Protheus.

I tried to include a record via SQL SERVER and was successful. I can check that the record was included in the table, but when I open totvs I do not find any records. What's the reason for this happening? Thank you right now!

Follows the error:

> Exceção ocorrida: : Error : 102 (37000) (RC=-1) - [Microsoft][ODBC SQL
> Server Driver][SQL Server]Sintaxe incorreta próxima a ''. ( From
> tMSSQLConnection::GetQueryFile ) Thread ID [8376] User [wdrik]    IO
> [13168]   Tables [9]  MaxTables [9]   Comment []  Status []   SP [ ]  Traced
> [No]  InTran [Yes]    DBEnv [MSSQL/P11]   DBThread [(SPID 53,54)] Started
> [02/10/2016 21:07:38] LastIO []   IP [127.0.0.1:1234] RCV [118535]    SND
> [501865]  TCBuild [20141119]   SELECT DISTINCT Z90.Z90_DESCRI,Z92.* FROM
> Z90990 Z90 , Z92990 Z92 WHERE  Z90.Z90_FILIAL = '  ' AND
> Z90.D_E_L_E_T_= ' ' AND Z92.Z92_FILIAL = '  ' AND Z92.D_E_L_E_T_= ' '
> AND Z92.Z92_EST IN ('SP' ) ''
 1
Author: Marcus Nunes, 2016-10-03

3 answers

Protheus creates several controls such as R_E_C_N_O_, in the table, when entering data via direct SQL you will have problems. In fact, you should use the automatic MATA010 routine to enter data into SA1.

Error skin you posted, seems to be error of some add-on Table.

 0
Author: KillerAll, 2016-11-09 00:40:22

Sometimes I have problems with changes directly in the bank, in some cases restarting the dbAccess/TopConnect solves the problem, but beware of changes on the outside, it is a not recommended practice. If it does not solve, delete the record by the bank (do not forget to update the RECDEL , if it exists) and make the inclusion or by the automatic routine, as the friend commented, or go to the apsdu and include manually.

 0
Author: Eduardo Pessoa, 2017-02-24 19:27:26

Hello Friend the error is in the executed syntax:

  SELECT DISTINCT Z90.Z90_DESCRI,Z92.* FROM Z90990 Z90 , Z92990 Z92 
WHERE   Z90.Z90_FILIAL = '  '   AND
        Z90.D_E_L_E_T_= ' '     AND 
        Z92.Z92_FILIAL = '  '   AND 
        Z92.D_E_L_E_T_= ' '     AND 
        Z92.Z92_EST IN ('SP' ) ''

Notice that there are quotes left at the end of the query ?, see the variable that treats the query and adjust these remaining characters.

A detail, whenever I make direct query call I do as follows:

cQuery := " UPDATE " + RetSqlName("ZBR")
cQuery += " SET ZBR_STATUS = '2' "
cQuery += " WHERE ZBR_DATA = '"+DTOS(_dDataPr)+"' "
cQuery += " AND ZBR_INTER  = '11' "
cQuery += " AND D_E_L_E_T_ = '' "
nRet := TcSqlExec( cQuery )
If nRet == 0
    // Deu certo
else
    // Faz algo se der errado
Endif
 0
Author: Bruno Dantas, 2017-05-25 19:04:34