error al borrar registro con xbrowse, tdophin, mysql

error al borrar registro con xbrowse, tdophin, mysql

Postby kpidata » Thu Jul 12, 2018 9:15 pm

Estimados tengo el siguiente problema, cuando hago una consulta tal como:

cTab_Modelo:=XServer:Query("SELECT cod_modelo, nom_modelo, cod_marca FROM tab_modelo ORDER BY cod_modelo")

le doy por eliminar un registro en particular, con esta instrucción, todo funciona

STATIC FUNCTION DelModelo(oBrw,cEmpresa,cAclave,cTab_Modelo)
cTab_Modelo:delete()
SetDolphin( oBrw, cTab_Modelo,.f. )
cTab_Modelo:Refresh()
oBrw:SetFocus()
oBrw:Refresh()
RETURN( NIL )

Pero si hago esto mismo, con una base relacionada.

cTab_Modelo:=xServer:Query("SELECT a.cod_modelo, a.nom_modelo, a.cod_marca, b.cod_marca, b.nom_marca FROM tab_modelo AS a LEFT JOIN tab_marca AS b ON a.cod_marca = b.cod_marca ORDER BY a.cod_modelo")

me tira error.. y es solo esto... el LEFT JOIN... me genera esto ???

Time from start: 0 hours 0 mins 43 secs
Error occurred at: 12/07/2018, 17:06:54
Error description: Error MYSQL/1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS a LEFT JOIN tab_marca AS b ON a.cod_marca = b.cod_marca WHERE cod_modelo = '2' at line 1
kpidata
 
Posts: 80
Joined: Tue Jul 26, 2016 9:52 pm

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby joseluisysturiz » Fri Jul 13, 2018 3:07 am

Saludos, tenia el mismo probela y la recomendacon es que uses el mismo comando SQL de la consulta para hacer el DELETE o como lo hago ahora, uses DELETE LOW_PIORITY, asi te borra el registro sin problemas, saludos... :shock:

https://dba.stackexchange.com/questions ... visibility
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby nageswaragunupudi » Sat Jul 14, 2018 1:32 pm

If you want to delete a record ( dolphin or any other ) when browsing, simply call:
Code: Select all  Expand view

oBrw:Delete()
 

This is simple to use.
Very safe.
If you use FWH builtin methods you do not commit bugs.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby joseluisysturiz » Sun Jul 15, 2018 1:36 am

nageswaragunupudi wrote:If you want to delete a record ( dolphin or any other ) when browsing, simply call:
Code: Select all  Expand view

oBrw:Delete()
 

This is simple to use.
Very safe.
If you use FWH builtin methods you do not commit bugs.


Mr RAO, cuando el registro que se va a borrar esta en una tabla relacionada(mysql), da error y no lo borra con oBrw:delete()...gracias... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby kpidata » Mon Jul 16, 2018 3:15 pm

Estimado, como se indica, el borrar solo opera a una tabla unica sin relacion de ningun tipo, pero si la relaciono, se cae la aplicación

En este caso, se me cae

cTab_Modelo:=xServer:Query("SELECT a.cod_modelo, a.nom_modelo, a.cod_marca, b.cod_marca, b.nom_marca FROM tab_modelo AS a LEFT JOIN tab_marca AS b ON a.cod_marca = b.cod_marca ORDER BY a.cod_modelo")

Time from start: 0 hours 0 mins 36 secs
Error occurred at: 16/07/2018, 11:08:14
Error description: Error MYSQL/1064 You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right
syntax to use near 'AS a LEFT JOIN tab_marca AS b ON a.cod_marca = b.cod_marca WHERE cod_modelo = '9' at line 1


Asi como se muestra, funciona bien
cTab_Modelo:=XServer:Query("SELECT cod_modelo, nom_modelo, cod_marca FROM tab_modelo ORDER BY cod_modelo")

esta es la funcion

STATIC FUNCTION DelModelo(oBrw,cEmpresa,cAclave,cTab_Modelo, cod_modelo)
Local cSql
If Alltrim(cAclave)=Alltrim( cEmpresa [15])
cTab_Modelo:delete()
SetDolphin( oBrw, cTab_Modelo,.f. )
cTab_Modelo:Refresh()
oBrw:SetFocus()
oBrw:Refresh()
Else
TipoMensaje("Usuario no habilitado")
Endif
RETURN( NIL )

y se invoca asi..

Redefine BtnBmp oBtn2[3] Id 103 Resource "BTO_BORRA" Of oDlg 2007;
ACTION (Del_Modelo(oBrw,cTab_Modelo,cEmpresa,cTab_Modelo:cod_modelo),cTab_Modelo:Refresh(),oBrw:Refresh(),oBrw:Gotop()) Tooltip "Permite Borrar y/o Eliminar Registro.."
kpidata
 
Posts: 80
Joined: Tue Jul 26, 2016 9:52 pm

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby cmsoft » Mon Jul 16, 2018 7:54 pm

Preuba Asi
Code: Select all  Expand view

STATIC FUNCTION DelModelo(oBrw,cEmpresa,cAclave,cTab_Modelo, cod_modelo)
Local cSql
If Alltrim(cAclave)=Alltrim( cEmpresa [15])
  if cTab_Modelo:IsSingleTable()
     cTab_Modelo:delete()
     ELSE
     XServer:Execute("DELETE FROM tab_modelo WHERE cod_modelo = " ClipValue2Sql(cTab_Modelo:cod_modelo))
  ENDIF  
  cTab_Modelo:Refresh()
  oBrw:SetFocus()
  oBrw:Refresh()
  Else
  TipoMensaje("Usuario no habilitado")
Endif
RETURN( NIL )
User avatar
cmsoft
 
Posts: 1285
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby joseluisysturiz » Tue Jul 17, 2018 1:46 am

kpidata wrote:Estimado, como se indica, el borrar solo opera a una tabla unica sin relacion de ningun tipo, pero si la relaciono, se cae la aplicación

En este caso, se me cae

cTab_Modelo:=xServer:Query("SELECT a.cod_modelo, a.nom_modelo, a.cod_marca, b.cod_marca, b.nom_marca FROM tab_modelo AS a LEFT JOIN tab_marca AS b ON a.cod_marca = b.cod_marca ORDER BY a.cod_modelo")

Time from start: 0 hours 0 mins 36 secs
Error occurred at: 16/07/2018, 11:08:14
Error description: Error MYSQL/1064 You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right
syntax to use near 'AS a LEFT JOIN tab_marca AS b ON a.cod_marca = b.cod_marca WHERE cod_modelo = '9' at line 1


Asi como se muestra, funciona bien
cTab_Modelo:=XServer:Query("SELECT cod_modelo, nom_modelo, cod_marca FROM tab_modelo ORDER BY cod_modelo")

esta es la funcion

STATIC FUNCTION DelModelo(oBrw,cEmpresa,cAclave,cTab_Modelo, cod_modelo)
Local cSql
If Alltrim(cAclave)=Alltrim( cEmpresa [15])
cTab_Modelo:delete()
SetDolphin( oBrw, cTab_Modelo,.f. )
cTab_Modelo:Refresh()
oBrw:SetFocus()
oBrw:Refresh()
Else
TipoMensaje("Usuario no habilitado")
Endif
RETURN( NIL )

y se invoca asi..

Redefine BtnBmp oBtn2[3] Id 103 Resource "BTO_BORRA" Of oDlg 2007;
ACTION (Del_Modelo(oBrw,cTab_Modelo,cEmpresa,cTab_Modelo:cod_modelo),cTab_Modelo:Refresh(),oBrw:Refresh(),oBrw:Gotop()) Tooltip "Permite Borrar y/o Eliminar Registro.."




REPITO MI RESPUESTA INICIAL...usa DELETE LOW_PIORITY, asi te borra el registro sin problemaso cambia DELETE por SELECT en la consulta por, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby nageswaragunupudi » Tue Jul 17, 2018 3:10 am

oBrw:Delete() in turn calls oQry:Delete() or oRs:Delete().

All the three libraries DOLPHIN, TMYSQL and ADO do NOT support Append, Modify, Delete operations on a query with join.

There is only one library, i.e., FWH MariaDB library that supports all operations Append, Modify and Delete of data in the main table of a query with joins also very smoothly. These operations work just like they work with a single table query. We can modify the joining field and we see a refreshed view of the row immediately. All this is done without requery. (Requery is time-consuming and puts undue strain on server and network traffic and good programming practices avoid requery unless essential).

FWH created the library not only to overcome the limitations of the existing librarries, but also provide for the very high end neeeds of Corporate programmers heavily relying on server-side scripting.

This sample program compares FWH Mariadb, Dolphin and ADO. Anyone having FWH 16.08 or later can compare all three libraries.
Code: Select all  Expand view

#include "fivewin.ch"

function Main()

   local nLib, oCn, oRs, cSql

   if ( nLib := Alert( "Select Library", { "FWH-MARIALIB", "ADO", "DOLPHIN" } ) ) == 0
      return nil
   endif

   oCn   := FW_DemoDB( { nil, "ADO", "DLP" }[ nLib ] )

   cSql  := "SELECT c.id, c.first as name, c.city, c.state as code, s.name as statename FROM customer c LEFT JOIN states s ON c.state = s.code ORDER by c.id"

   if nLib == 1
      oRs   := oCn:RowSet( cSql )
   elseif nLib == 2
      oRs   := FW_OpenRecordSet( oCn, cSql )
   else // nLib == 3
      oRs   := oCn:Query( cSql )
   endif

   XBROWSER oRs FASTEDIT

   if nLib == 3
      oRs:End()
      oCn:End()
   else
      oRs:Close()
      oCn:Close()
   endif

return nil

EXTERNAL TDOLPHINSRV
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: error al borrar registro con xbrowse, tdophin, mysql

Postby joseluisysturiz » Tue Jul 17, 2018 6:51 am

GOOGLE TRASLATOR

Mr RAO, thank you very much for your explanation, I think it's time to move my systems to the FWH Mariadb library to jump the limitations of the good LIB Dolphin and ADO that gave the initiative to their improvements with FWH Mariadb and thus increase security of data and speed of processes, thanks... :shock:

Mr RAO, muchas gracias por su explicacion, creo que es hora de ir pasando mis sistemas a la libreria FWH Mariadb para asi saltar las limitaciones de las buenas LIB Dolphin and ADO que dieron la iniciativa a sus mejoras con FWH Mariadb y asi aumentar la seguridad de la data y rapidez de los procesos, gracias... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 53 guests

cron