Pasar query a un arreglo

Re: Pasar query a un arreglo

Postby nageswaragunupudi » Mon Jul 01, 2019 3:34 am

Documentation:

For documentation of Connection class and Rowset class, please see these postings:
viewtopic.php?f=3&t=33286

Please see the documentation in WIKI:
http://wiki.fivetechsoft.com/doku.php?i ... connection

http://wiki.fivetechsoft.com/doku.php?i ... ariarowset

Samples:

fwh\samples\maria01.prg ... maria*.prg

Migration:

To use native FWH lib, you need not migrate your entire application. You can continue to run your application in Dolphin and use native libs for new modules only.

If you are already connected to the server with Dolphin, you can easily get fwmariadb connection like this;
Code: Select all  Expand view

oCn := maria_Connect( oServer ) // where oServer is Dolphin server
 

and start using FWH native libs for new modules or some work in the same modules. In other words, you can use both dolphin and fwh libs at the same time side by side.

Over a period of time, you can convert existing modules at your convenience.
Regards

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

Re: Pasar query a un arreglo

Postby joseluisysturiz » Mon Jul 01, 2019 3:56 am

Thank you very much for your help... :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: Pasar query a un arreglo

Postby nageswaragunupudi » Mon Jul 01, 2019 4:25 am

May I know your FWH version?
Regards

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

Re: Pasar query a un arreglo

Postby joseluisysturiz » Mon Jul 01, 2019 4:36 am

nageswaragunupudi wrote:May I know your FWH version?

18.05, 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: Pasar query a un arreglo

Postby nageswaragunupudi » Mon Jul 01, 2019 5:18 am

In FWH1805, only the simple syntax oRs:GetRows() works without any parameters.
The extended syntax given above works from FWH1807.
Regards

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

Re: Pasar query a un arreglo

Postby joseluisysturiz » Tue Jul 02, 2019 12:47 am

nageswaragunupudi wrote:In FWH1805, only the simple syntax oRs:GetRows() works without any parameters.
The extended syntax given above works from FWH1807.

Ok, lo tendre en cuenta e ire probando que puedo hacer, gracias...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: Pasar query a un arreglo

Postby goosfancito » Fri Oct 01, 2021 3:57 am

hola
si quiero que me devuelva un array para luego usarlo en un combobox,

Code: Select all  Expand view
METHOD cargarSucursales()
   LOCAL cSql, oQry

   TEXT into cSql
   Select
   s.nombre
   FROM tbsucursal s
   order by s.nombre
   ENDTEXT

   oQry:= ::oCnx:QUERY(cSql)

   RETURN oQry:getRows("nombre")


eso me devuelve un ARRAY multidimensional, yo solo quiero esto:
"sucursal 1"
"sucursal 2"
"sucursal 3"
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Pasar query a un arreglo

Postby nageswaragunupudi » Fri Oct 01, 2021 6:39 am

Code: Select all  Expand view
aList := ArrTranspose( ::oCnx:Execute( "select nombre from tbsucursal order by nombre" ) )[ 1 ]
 
Regards

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

Re: Pasar query a un arreglo

Postby goosfancito » Sun Dec 05, 2021 9:37 am

Me gustaría (si es que ya no existe) que getRows te de la posibilidad de agregar columnas vacias al array,

Por ejemplo:
Supongamos que la consulta devuelva 2 columas: id, nombre y 5 rows. Que yo pueda hacer esto:

a:= oQry:getRows(, {"id", "nombre", 0.0, .f.})

y el resultado seria
a:= [
1, "gustavo", 0.0, .f.,
2, "miguel", 0.0, .f.
3, "angel", 0.0, .f.
4, "velazquez", 0.0, .f.
5, "fernandez", 0.0, .f.
]
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Pasar query a un arreglo

Postby nageswaragunupudi » Sun Dec 05, 2021 5:21 pm

Code: Select all  Expand view
a:= oQry:getRows( nil, nil, {"id", "nombre", { || 0.0 }, { || .f. } } )
// OR
a := oQry:GetRows( nil, nil, { "id", "nombre", "0.0". ".f." } )
 


"0.0" and ".f." will be returned as numeric 0.0 and logical .f..
Regards

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

Previous

Return to FiveWin para Harbour/xHarbour

Who is online

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