Hola.
Quiero migrar.
Hay algo mejor que la lib TDolphin?
gracias.
goosfancito wrote:yo lo que necesito es no andar peleando tanto cuando tengo un error o se produce un error.
siempre que pasa un error al ejecutar un comando no es claro en el error que produce.
gracias.
joseluisysturiz wrote:en mi caso antes de hacer una consulta en programacion, la hago y voy probado en un administrador de MySql, uso NAVICAT, y de verdad ayuda mucho ya que te dice el error y como es en linea, no tengo que estar recompilando ni buscando entre el codigo, es solo una sugerencia y humilde comentario, se que no es facil detectar los errores en MySql, pero si te ayudas de la forma que te comento, evitaras mucho. Cuando veo que mi consulta esta funcional, entonces simplemente la copio y pego en mi programa..espero te sirva de ayuda, saludos...
::oCnx:insert( "tb", ;
{;
"idefector", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", ;
"c10", "c11", "c12", "c13", "c14", "c15", "c16", "c17", "c18", "c19", ;
"c20", "c21", "c22", "c23", "c24", "c25", "c26", "c27", "c28", "c29", ;
"c30", "c31", "c32", "c33", "c34", "c35", "c36", "c37", "c38", "c39", ;
"c40", "c41", "c42", "c43", "c44", "c45", "c46", "c47", "c48", "c49", ;
"c50", "c51", "c52", "c53", "c54", "c55", "c56", "c57", "c58", "c59", ;
"c60", "c61", "c62", "c63", "c64", "c65", "c66", "c67", "c68", "c69", ;
"c70", "c71", "c72", "c73", "c74", "c75", "c76", "c77", "c78", "c79", ;
"c80", "ck";
}, ;
{;
ClipValue2SQL(::nIdEfector),;
::vGet[01] , ::vGet[02] , ::vGet[03] , ::vGet[04] , ::vGet[05] ,;
::vGet[06] , ::vGet[07] , ::vGet[08] , ::vGet[09] , ::vGet[10] ,;
::vGet[11] , ::vGet[12] , ::vGet[13] , ::vGet[14] , ::vGet[15] ,;
::vGet[16] , ::vGet[17] , ::vGet[18] , ::vGet[19] , ::vGet[20] ,;
::vGet[21] , ::vGet[22] , ::vGet[23] , ::vGet[24] , ::vGet[25] ,;
::vGet[26] , ::vGet[27] , ::vGet[28] , ::vGet[29] , ::vGet[30] ,;
::vGet[31] , ::vGet[32] , ::vGet[33] , ::vGet[34] , ::vGet[35] ,;
::vGet[36] , ::vGet[37] , ::vGet[38] , ::vGet[39] , ::vGet[40] ,;
::vGet[41] , ::vGet[42] , ::vGet[43] , ::vGet[44] , ::vGet[45] ,;
::vGet[46] , ::vGet[47] , ::vGet[48] , ::vGet[49] , ::vGet[50] ,;
::vGet[51] , ::vGet[52] , ::vGet[53] , ::vGet[54] , ::vGet[55] ,;
::vGet[56] , ::vGet[57] , ::vGet[58] , ::vGet[59] , ::vGet[60] ,;
::vGet[61] , ::vGet[62] , ::vGet[63] , ::vGet[64] , ::vGet[65] ,;
::vGet[66] , ::vGet[67] , ::vGet[68] , ::vGet[69] , ::vGet[70] ,;
::vGet[71] , ::vGet[72] , ::vGet[73] , ::vGet[74] , ::vGet[75] ,;
::vGet[76] , ::vGet[77] , ::vGet[78] , ::vGet[79] , ::vGet[80] ,;
ck;
})
FUNCTION Programacion_Grabar( lNuevo )
LOCAL lGrabado := FALSE
LOCAL nNumSoli
TRY
oServer:BeginTransaction()
IF lNuevo .and. ( nNumSoli := IncContador( "CONT_SOLI" ) ) > 0
oServer:Insert2( "PROGRAMACION", { { "NUM_SOLI" , nNumSoli }, ;
{ "NUM_PRES" , 0 }, ;
{ "NUM_CIUD" , nNumCiud }, ;
{ "NUM_CLIE" , nNumClie }, ;
{ "PLAZO" , nPlaSoli }, ;
{ "TIPO_PRES" , cTipPres }, ;
{ "MONTO_SOLI" , nMonSoli }, ;
{ "MONTO_APRO" , nMonApro }, ;
{ "FECHA_SOLI" , dFecSoli }, ;
{ "FECHA_APRO" , dFecApro }, ;
{ "FECHA_DESE" , dFecDese }, ;
{ "REVISADO" , lSolRevi }, ;
{ "APROBADO" , lSolApro }, ;
{ "ADESEMBOLS" , FALSE }, ;
{ "ENTREGADO" , FALSE }, ;
{ "INSPECCION" , nNumInsp }, ;
{ "EXTRA" , lEsExtra }, ;
{ "NOTA" , cNotSoli } } )
ELSE
cWhere := "MY_RECNO=" + Var2Str( nMy_RecNo )
oServer:Update2( "PROGRAMACION", { { "PLAZO" , nPlaSoli }, ;
{ "TIPO_PRES" , cTipPres }, ;
{ "MONTO_SOLI" , nMonSoli }, ;
{ "MONTO_APRO" , nMonApro }, ;
{ "FECHA_SOLI" , dFecSoli }, ;
{ "FECHA_APRO" , dFecApro }, ;
{ "FECHA_DESE" , dFecDese }, ;
{ "REVISADO" , lSolRevi }, ;
{ "APROBADO" , lSolApro }, ;
{ "INSPECCION" , nNumInsp }, ;
{ "EXTRA" , lEsExtra }, ;
{ "NOTA" , cNotSoli } }, cWhere )
ENDIF
oServer:CommitTransaction()
IIf( lNuevo, oQryCtrl:ReQuery(), NIL )
oQryProg:ReQuery()
lGrabado := TRUE
CATCH oError
oServer:RollBack()
ShowError( oError )
END
IF lGrabado
IIf( lNuevo, oBrw:RefreshTotals( FALSE ), oBrw:RefreshTotals( TRUE ) )
ELSE
oBrw:GoTop()
ENDIF
RETURN lGrabado
...
EXTEND CLASS TDOLPHINQRY WITH METHOD FillDbf
EXTEND CLASS TDOLPHINSRV WITH METHOD Query2
EXTEND CLASS TDOLPHINSRV WITH METHOD Execute2
EXTEND CLASS TDOLPHINSRV WITH METHOD Insert2
EXTEND CLASS TDOLPHINSRV WITH METHOD Update2
...
/*-------------------------------------------------------------------------------------------------*/
//TDOLPHINQRY
FUNCTION FillDbf( cTable, cAlias, bOnStart, bOnEnd )
LOCAL Self := HB_QSelf()
LOCAL lCreated := FALSE
LOCAL aStructure := {}
LOCAL x, cOldAlias := Alias()
DEFAULT cTable := "SQLRESULT", cAlias := cTable, bOnStart := {|| NIL }, bOnEnd := {|| NIL }
Eval( bOnStart, Self )
IF SELECT( cAlias ) > 0
(cAlias)->( DBCloseArea() )
ENDIF
nCountF := ::FCount()
FOR x := 1 TO nCountF
AAdd( aStructure, { ::FieldName(x), ::FieldType(x), ::FieldLen(x), FieldDec(x) } )
NEXT
TRY
DBCreate( cTable, aStructure, "DBFCDX", TRUE, cAlias )
::GoTop()
DO WHILE !::Eof()
(cAlias)->( DBAppend() )
FOR x := 1 TO nCountF
(cAlias)->( FieldPut(x, ::FieldGet(x) ) )
NEXT
::Skip()
ENDDO
::GoTop()
(cAlias)->( DBGoTop() )
lCreated := TRUE
CATCH
IF SELECT( cAlias ) > 0
(cAlias)->( DBCloseArea() )
ENDIF
lCreated := FALSE
END
IF !Empty(cOldAlias)
DBSelectArea( cOldAlias )
ENDIF
Eval( bOnEnd, Self )
RETURN lCreated
/*-------------------------------------------------------------------------------------------------*/
FUNCTION Query2( cQuery, aParameters, lShow )
LOCAL Self := HB_QSelf()
LOCAL xParameter
LOCAL cQuery2, x
DEFAULT aParameters := NIL , ;
lShow := FALSE
IF HB_IsArray( aParameters )
FOR x := 1 TO Len( aParameters )
cQuery := StrTran( cQuery, "%" + Num2Str( x ), Var2Str( aParameters[ x ] ) )
NEXT
cQuery2 := cQuery
ELSE
cQuery2 := cQuery
ENDIF
IF lShow
MsgInfo( cQuery2 )
ENDIF
RETURN ::Query( cQuery2 )
/*-------------------------------------------------------------------------------------------------*/
//TDOLPHINSRV
FUNCTION Execute2( cQuery, aParameters, lShow )
LOCAL Self := HB_QSelf()
LOCAL xParameter
LOCAL cQuery2, x
DEFAULT aParameters := NIL, lShow := FALSE
IF HB_IsArray( aParameters )
FOR x := 1 TO Len( aParameters )
cQuery := StrTran( cQuery, "%" + Num2Str( x ), Var2Str( aParameters[ x] ) )
NEXT
cQuery2 := cQuery
ELSE
cQuery2 := cQuery
ENDIF
IF lShow
MsgInfo( cQuery2 )
ENDIF
RETURN ::Execute( cQuery2 )
/*-------------------------------------------------------------------------------------------------*/
//TDOLPHINSRV
FUNCTION Insert2( cTable, aFV )
LOCAL Self := HB_QSelf()
LOCAL aItems
LOCAL aFlds := {}
LOCAL aVals := {}
FOR EACH aItems IN aFV
IF HB_IsString( aItems[ 02 ] )
aItems[ 02 ] := LTrim( aItems[ 02 ] )
ENDIF
AAdd( aFlds, aItems[ 01 ] )
AAdd( aVals, aItems[ 02 ] )
NEXT
RETURN ::Insert( cTable, aFlds, aVals )
/*-------------------------------------------------------------------------------------------------*/
//TDOLPHINSRV
FUNCTION Update2( cTable, aFV, cWhere )
LOCAL Self := HB_QSelf()
LOCAL aItems
LOCAL aFlds := {}
LOCAL aVals := {}
FOR EACH aItems IN aFV
IF HB_IsString( aItems[ 02 ] )
aItems[ 02 ] := LTrim( aItems[ 02 ] )
ENDIF
AAdd( aFlds, aItems[ 01 ] )
AAdd( aVals, aItems[ 02 ] )
NEXT
RETURN ::Update( cTable, aFlds, aVals, cWhere )
FUNCTION Num2Str( nNum )
RETURN AllTrim( CStr( nNum ) )
/*-------------------------------------------------------------------------------------------------*/
FUNCTION Var2Str( xValue )
LOCAL cValue := "''"
LOCAL cType := ValType( xValue )
DO CASE
CASE cType=="C"
cValue := "'" + AllTrim( xValue ) + "'"
CASE cType=="M"
cValue := "'" + xValue + "'"
CASE cType=="N"
cValue := Num2Str( xValue )
CASE cType=="L"
cValue := IIf( xValue, '1', '0' )
CASE cType=="D"
cValue := "'" + Transform( DToS( xValue ), "@R 9999-99-99" ) + "'"
CASE cType=="T"
cValue := "'" + Transform( TToS( xValue ), "@R 9999-99-99 99:99:99" ) + "'"
ENDCASE
RETURN cValue
cQry:="INSERT INTO TB(MESP,CODIGO,NOMBRE,DETALLE) VALUES ( "
cQry+=ClipValue2SQL(cMesP)+ ","
cQry+=ClipValue2SQL(cCODIGO)+ ","
cQry+=ClipValue2SQL(cNOMBRE)+ ","
cQry+=ClipValue2SQL(cQUE)+ " )"
oTB:oServer:SqlQuery( cQry )
oTB:Refresh()
cQry:="INSERT INTO TB( IDEFECTOR,"
For I=1 to 80
cQry+="C"+AllTrim(Str(I))+","
Next I
cQry+="CK) VALUES ( "+ClipValue2SQL(nIdEfector)+ ","
For I=1 to 80
cQry+=ClipValue2SQL(vGet[I])+","
Next I
cQry+=ClipValue2SQL(ck)+ " )"
oTB:oServer:SqlQuery( cQry )
oTB:Refresh()
cQuery:="bla bla bla bla"
IF lDebug // Esta variable la tengo en un .ini que la cambio en caso de tener que analizar el query.
LogErrorQuery(cQuery)
ENDIF
oQuery:=oServer:Execute(cQuery)
// GRABO EL QUERY QUE GENERO ERROR PARA LUEGO ANALIZARLO //
Function LogErrorQuery(cQuery)
Local Arch,cBuffer,ArchLog
ArchLog:=PathSist+"\ERRORES\Q"+DTOS(DATE())+".LOG"
cBuffer:=CHR(13)+" "
cBuffer:=cBuffer+CHR(13)+REPLI("*",80)
cBuffer:=cBuffer+CHR(13)+" "
cBuffer:=cBuffer+CHR(13)+"ERROR EN QUERY"
cBuffer:=cBuffer+CHR(13)+"=============="
cBuffer:=cBuffer+CHR(13)+" "
cBuffer:=cBuffer+CHR(13)+"USUARIO: "+cUser
cBuffer:=cBuffer+CHR(13)+"FECHA : "+DTOC(DATE())
cBuffer:=cBuffer+CHR(13)+"HORA : "+TIME()
cBuffer:=cBuffer+CHR(13)+" "
cBuffer:=cBuffer+CHR(13)+"QUERY: "+cQuery
cBuffer:=cBuffer+CHR(13)+" "
cBuffer:=cBuffer+CHR(13)+REPLI("*",80)
cBuffer:=cBuffer+CHR(13)+" "
IF !FILE(ArchLog)
Arch1:=FCREATE(ArchLog)
FCLOSE(Arch1)
ENDIF
Arch1:=FOPEN(ArchLog,2)
FSEEK(Arch1,0,2)
FWRITE(Arch1, cBuffer )
FCLOSE(Arch1)
Return nil
//
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 17 guests