FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour how to assign the sql query results to the variable
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM
how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 06:59 AM
Hi,

how to assign the sql query results
Code (fw): Select all Collapse
select sum(value) from invoice where poz='123'
to the variable?


regards
Miloš
Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 07:30 AM
mtajkov wrote:Hi,

how to assign the sql query results
Code (fw): Select all Collapse
select sum(value) from invoice where poz='123'
to the variable?


regards
Miloš


Code (fw): Select all Collapse
select sum(value) as newname from invoice where poz='123'


EMG
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 08:26 AM
The result is constantly 0?

Code (fw): Select all Collapse
Function New() 
Local NewName:=0

 oSql:exec("SELECT sum(Value) AS NewName FROM Invice WHERE poz='123')

MsgInfo(NewName)

return
Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 09:27 AM

What is oSql? Can I see a complete sample?

EMG

Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 09:37 AM

Try

Local oN
oN := oSql:exec("SELECT sum(Value) AS NewName FROM Invice WHERE poz='123')
xbrowse(oN)

Maurizio

www.nipeservice.com

Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 06:43 PM
mtajkov wrote:The result is constantly 0?

Code (fw): Select all Collapse
Function New() 
Local NewName:=0

 oSql:exec("SELECT sum(Value) AS NewName FROM Invice WHERE poz='123')

MsgInfo(NewName)

return


Code (fw): Select all Collapse
cSQL := "SELECT sum(Value) AS NewName FROM Invice WHERE poz='123'"

oSql:exec( cSql,,.t.,@aData )

NewName := aData[1][1]

:-) :-)
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM
Re: how to assign the sql query results to the variable
Posted: Wed Sep 06, 2017 05:01 AM

Thank you, it works. :D

Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: how to assign the sql query results to the variable
Posted: Thu Sep 07, 2017 02:29 AM
Obteniendo resultado a una variable, saludos... :-)

Code (fw): Select all Collapse
oQryId := TDolphinQry():New( "SELECT last_insert_id() AS nId", oDatos:oConex )
nVar := oQryId:nId
Dios no está muerto...



Gracias a mi Dios ante todo!

Continue the discussion