Page 1 of 1
how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 6:59 am
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š
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 7:30 am
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
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 8:26 am
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
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 9:27 am
by Enrico Maria Giordano
What is oSql? Can I see a complete sample?
EMG
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 9:37 am
by Maurizio
Try
Local oN
oN := oSql:exec("SELECT sum(Value) AS NewName FROM Invice WHERE poz='123')
xbrowse(oN)
Maurizio
www.nipeservice.com
Re: how to assign the sql query results to the variable
Posted: Tue Sep 05, 2017 6:43 pm
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]
Re: how to assign the sql query results to the variable
Posted: Wed Sep 06, 2017 5:01 am
by mtajkov
Thank you, it works.
Re: how to assign the sql query results to the variable
Posted: Thu Sep 07, 2017 2:29 am
by joseluisysturiz
Obteniendo resultado a una variable, saludos...
Code: Select all
oQryId := TDolphinQry():New( "SELECT last_insert_id() AS nId", oDatos:oConex )
nVar := oQryId:nId