how to assign the sql query results to the variable

Post Reply
mtajkov
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

how to assign the sql query results to the variable

Post by mtajkov »

Hi,

how to assign the sql query results

Code: Select all | Expand

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) ]
User avatar
Enrico Maria Giordano
Posts: 8734
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 1 time
Contact:

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

Post by Enrico Maria Giordano »

mtajkov wrote:Hi,

how to assign the sql query results

Code: Select all | Expand

select sum(value) from invoice where poz='123'
to the variable?


regards
Miloš


Code: Select all | Expand

select sum(value) as newname from invoice where poz='123'


EMG
mtajkov
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

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

Post by mtajkov »

The result is constantly 0?

Code: Select all | Expand

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) ]
User avatar
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

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

Post by Maurizio »

Try

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

Maurizio
www.nipeservice.com
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

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

Post by fafi »

mtajkov wrote:The result is constantly 0?

Code: Select all | Expand

Function New()
Local NewName:=0

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

MsgInfo(NewName)

return


Code: Select all | Expand



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

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

NewName := aData[1][1]

 

:D :D
mtajkov
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

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

Post by mtajkov »

Thank you, it works. :D
Best regards
Milos

[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
User avatar
joseluisysturiz
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela
Contact:

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

Post by joseluisysturiz »

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

Code: Select all | Expand


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

Gracias a mi Dios ante todo!
Post Reply