Cambiar columna de consulta TDolphin

Cambiar columna de consulta TDolphin

Postby JoseAlvarez » Thu Apr 14, 2022 6:02 pm

Feliz Semana Santa para todos. Saludos.

Necesito cambiar el valor de una columna a un query. Me Explico:

Code: Select all  Expand view
    cQuery := "SELECT "
    cQuery += "existencia "
    cQuery += "FROM Tabla "
    cQuery += "WHERE "
    cQuery += "codigo_articulo=655"

    oQuery:=_oSqlConex:Query( cQuery )


Eso lo muestro en un lisxbox y todo bien.
hay un solo registro y la existencia es 3

Image

pero luego quiero a esa columna existencia, sumarle una cantidad adicional, como por ejemplo, 5, quedaria en 8 y hago lo siguiente:

oQuery:existencia := oQuery:existencia+5

Si dentro del programa hago un

? oQuery:existencia

me da bien, 8 ... pero al regresar, el listbox me sigue mostrando 3

Ya intenté con el refresh del listbox y del oQuery (no se si eso exista, pero no me da error) y tambien reasingando de nuevo el arreglo con

oLbx:SetArray(oQuery),
oLbx:refresh()

pero nada funciona...

que esta mal?

Uso fw 17.01 + xHarbour + MariaDB + TDolphin y el viejo y fiel listbox de cecarrelli.
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Cambiar columna de consulta TDolphin

Postby nageswaragunupudi » Thu Apr 14, 2022 6:23 pm

Code: Select all  Expand view
oQuery:existence := oQuery:existence+5
oQuery:Save()
 
Regards

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

Re: Cambiar columna de consulta TDolphin

Postby JoseAlvarez » Thu Apr 14, 2022 6:30 pm

Hi Mr Rao,
Thanks for you support

Don't work to me..

I have this error back


Application
===========
Path and name: C:\Neuro32\Neuro32.EXE (32 bits)
Size: 8,018,944 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20170215)
FiveWin Version: FWHX 14.06
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 9 secs
Error occurred at: 14/04/2022, 14:27:46
Error description: Error BASE/1004 Class: 'LOGICAL' has no exported method: EVAL
Args:
[ 1] = L .T.
[ 2] = O TDOLPHINSRV
[ 3] = N 9016
[ 4] = L .T.
[ 5] = U

Stack Calls
===========
Called from: => EVAL( 0 )
Called from: .\source\prg\tdolpsrv.prg => TDOLPHINSRV:CHECKERROR( 836 )
Called from: .\source\prg\tdolpqry.prg => (b)TDOLPHINQRY:TDOLPHINQRY( 133 )
Called from: => TDOLPHINQRY:CHECKERROR( 0 )
Called from: .\source\prg\tdolpqry.prg => TDOLPHINQRY:SAVE( 1480 )
Called from: .\prg\ArticuloNumeros.PRG => FNCT_SUMAEXISTENCIAS( 332 )
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Cambiar columna de consulta TDolphin

Postby nageswaragunupudi » Fri Apr 15, 2022 4:40 am

Another point.
Code: Select all  Expand view
oLbx:SetArray(oQuery),
oLbx:refresh()
 


Why this code?
oQry is not an array and we can not use SetArray()
Regards

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

Re: Cambiar columna de consulta TDolphin

Postby nageswaragunupudi » Fri Apr 15, 2022 4:46 am

Next point:
Do you have a primary key for the table "tabla"?
You need to include primary key also in the SELECT statement. This helps Dolphin to save the changes to the correct row.
Regards

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

Re: Cambiar columna de consulta TDolphin

Postby nageswaragunupudi » Fri Apr 15, 2022 1:20 pm

Please try this program:
We used a cloud server belonging to FWH. You can run this program, without changing the server.

Code: Select all  Expand view
#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oCn, oQry

   oCn   := TDolphinSrv():New( "208.91.198.197", "gnraofwh", "Bharat@1950", 3306, nil, "fwhdemo" )

   if oCn == nil
      ? "connect fail"
      return nil
   endif

   ? "Connected"

   oQry  := oCn:Query( "SELECT ID,SALARY FROM customer WHERE ID < 6" )

   ? oQry:Salary
   oQry:Salary += 12345
   oQry:Save()

   ? oQry:Salary
   XBROWSER oQry

   oQry:End()
   oCn:End()

return nil


 
Regards

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

Re: Cambiar columna de consulta TDolphin

Postby JoseAlvarez » Sat Apr 16, 2022 4:44 pm

Why this code?
oQry is not an array and we can not use SetArray()



Hello again mr. Rao.
Let me explain

I am relatively new using Mariadb (MySQL) and TDolphin.

I know that the result of a query is an object and not an arrangement.

However, in some opportunities I have handled it as such.
When I want to refer to the values ​​of the query, I do for example:

cName := oQuery: description
nCost := oQuery:cost
nQuantity := oQuery:existence

And it has worked well.

I always used the Hernan Cecarreli listbox.
And my first applications applications with MySQL and TDolphin still have it, and I use it as:

oLbx: SetArray (oQuery)

And until the moments, it has worked well.

Other times I need to make an arrangement when I must change the values ​​of the oquery, for example:

aArray: = oQuery: FillArray ()

but in this way I must use memory arrangements and handle the
Elements in the same order and blindly.

I have to be checking my PRG from top to bottom to remember the positions of the variables within the arrangement.
Work like this is very heavy and loss of time.

In my last system (which is currently under development) I began using the Xbrowse and I use it as:

aKardex: = oQuery: = FillArray ()

Redefine XBrowse Obrwkdx ID 4001 DataSource Akardex


But I still have to work by remembering memory positions.
What suggests me to work better and more comfortable with mariadb using the CECARRELI Listbox or using the Xbrowse?

I would appreciate help and guidance, because I think I lose time and use a lot of code in the way I do.


Next Point:
DO YOU HAVE A PRIMARY KEY FOR THE TABLE "TABLE"?
You Need To Include Primary Key Also In The Select Statement. This Helps Dolphin to Save The Changes To The Correct Row.


The query involves several tables, does not have a unique index.
I already resolved by creating a function in Mariadb (I did not know that they existed, I found it on Google) and I see that they are very useful
I think they will save me headaches in complex query.

I appreciate your suggestions to improve and optimize my codes.
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Cambiar columna de consulta TDolphin

Postby CARLOS ATUNCAR » Sat Apr 30, 2022 11:42 pm

Te comento mi experiencia trabajo con xbrowse y tdolphin para hacer ese trabajo donde hay que modificar los valores lo trabajo por columna con una funcion que al terminar la edicion actualice la tabla y refresh la consulta por que la informacion de esta en pantalla tiene q estar guardada en la tabla, y si necesito tener informacion temporal que manipular y al final actualizar a la tabla las manejo en una DBF temporal y luego las envio a la tabla
CARLOS ATUNCAR
 
Posts: 117
Joined: Thu Sep 17, 2015 11:40 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests