how to assign the sql query results to the variable

Post Reply
mtajkov
Posts: 100
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

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


regards
Miloš
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
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

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


regards
Miloš

Code: Select all

select sum(value) as newname from invoice where poz='123'
EMG
mtajkov
Posts: 100
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

Function New() 
Local NewName:=0

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

MsgInfo(NewName)

return
User avatar
Maurizio
Posts: 705
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

Function New() 
Local NewName:=0

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

MsgInfo(NewName)

return

Code: Select all


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

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

NewName := aData[1][1]

 
:D :D
mtajkov
Posts: 100
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
User avatar
joseluisysturiz
Posts: 2024
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

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