how to assign the sql query results to the variable

how to assign the sql query results to the variable

Postby mtajkov » Tue Sep 05, 2017 6:59 am

Hi,

how to assign the sql query results
Code: Select all  Expand view  RUN
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) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Re: how to assign the sql query results to the variable

Postby Enrico Maria Giordano » Tue Sep 05, 2017 7:30 am

mtajkov wrote:Hi,

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


regards
Miloš


Code: Select all  Expand view  RUN
select sum(value) as newname from invoice where poz='123'


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: how to assign the sql query results to the variable

Postby mtajkov » Tue Sep 05, 2017 8:26 am

The result is constantly 0?

Code: Select all  Expand view  RUN
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) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm


Re: how to assign the sql query results to the variable

Postby Maurizio » Tue Sep 05, 2017 9:37 am

Try

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

Maurizio
www.nipeservice.com
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Re: how to assign the sql query results to the variable

Postby fafi » Tue Sep 05, 2017 6:43 pm

mtajkov wrote:The result is constantly 0?

Code: Select all  Expand view  RUN
Function New()
Local NewName:=0

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

MsgInfo(NewName)

return


Code: Select all  Expand view  RUN


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

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

NewName := aData[1][1]

 

:D :D
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: how to assign the sql query results to the variable

Postby mtajkov » Wed Sep 06, 2017 5:01 am

Thank you, it works. :D
Best regards
Milos

[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Re: how to assign the sql query results to the variable

Postby joseluisysturiz » Thu Sep 07, 2017 2:29 am

Obteniendo resultado a una variable, saludos... :shock:

Code: Select all  Expand view  RUN

oQryId := TDolphinQry():New( "SELECT last_insert_id() AS nId", oDatos:oConex )
nVar := oQryId:nId
 
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 for Harbour/xHarbour

Who is online

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