Page 1 of 1

Consulta MariaDBConnection

Posted: Fri Apr 16, 2021 3:13 pm
by MarioG
Buenos dias!
Hago esta consulta:

Code: Select all

::oConn0:RowSet("SET @nCredito=0.00;" + ;
                "SELECT FeCobro AS Fecha, PuntoVta, CompNro, CompTipo, CompxNC," + ;
                "CONCAT( RTrim(TUT.TutorFac),' ',if(CompTipo=13, 'NC a Rbo.Nº', ''),' ',if(CompTipo=13,CONVERT(RIGHT(CompxNC,8),SIGNED),'') ) AS Detalle," + ;
                "MntoNeto, MntoCobrado AS Facturado, @nCredito AS Credito, TUT.id_tutor " + ;
                "FROM cabercbos AS RCBO " )
Me devuelve error: Invalid SQL: SET @nCredito=0.00;

Cual es la forma correcta?; gracias!

Re: Consulta MariaDBConnection

Posted: Fri Apr 16, 2021 11:37 pm
by MarioG
He encontrado mi error.
Debo usar EXECUTE, no ROWSET
De manera que hago esto: (considerando que puedo estar errado)

Code: Select all

   ::oConn0:Execute( "SET @nCredito=0.00" )
   oQryViewFac:= ::oConn0:RowSet("SELECT FeCobro AS Fecha, PuntoVta, CompNro, CompTipo, CompxNC," + ;
                                 "CONCAT( RTrim(TUT.TutorFac),' ',if(CompTipo=13, 'NC a Rbo.Nº', ''),' ',if(CompTipo=13,CONVERT(RIGHT(CompxNC,8),SIGNED),'') ) AS Detalle," + ;
                                 "MntoNeto, MntoCobrado AS Facturado, @nCredito AS Credito, TUT.id_tutor " + ;
                                 "FROM cabercbos AS RCBO " + ;
                                 "LEFT JOIN vista_tutores AS TUT ON TUT.id_tutor=RCBO.id_tutor " + ;
                                 "WHERE RCBO.id_tutor="+FW_ValToSQL(nIDTutor)+" AND FeCobro BETWEEN ? AND ?" + ;
                                 " ORDER BY FeCobro DESC,CompNro DESC", {dFeIni, dFeFin} )
Hasta acá la respuesta es la deseada.
Luego a esto lo presento en un xBrowse, donde @nCredito AS Credito es la columna 5

Code: Select all

      REDEFINE XBROWSE aO[_oBrwCF] ID BRW_XBRW OF oDlg AUTOSORT ;
               COLUMNS aColumns[_FeCobro], aColumns[_CompNum], aColumns[_Detalle], aColumns[_Facturado], aColumns[_Credito] ;
               HEADERS aHeaders[_FeCobro], aHeaders[_CompNum], aHeaders[_Detalle], aColumns[_Facturado], aColumns[_Credito] ;
               OBJECT oQryViewFac  FASTEDIT
Y de acá pretendo que tal columna 5 (Credito) sea editable

Code: Select all

:bOnPostEdit:= {|o,nC,nK| if( nK != VK_ESCAPE, o:Value:= nC , ) }
Como se puede ver, el xbrowse es FASTEDIT. Y ocurre que no hace nada ni al teclear un numero, ni al pulsar RETURN