1
I’m struggling to do something that should be very simple.
I created a custom field for a table called SALDO
.
In my code is made a SELECT
to access the records that interest me with an alias TMP
. After that SELECT
I loop these records and show them to my user in product list form. My user will change some values of the aCols
and based on what it changes I must make a calculation and save that value in the bank in the field SALDO
of this such record, but I am not able to do it. What I tried and failed is the following:
DbSelectArea("TABELA")
RecLock("TMP2", .F.)
TMP2->SALDO := 400
MSUnLock()
I can’t post my full code by company policy but an outline of how it works can be seen below:
_cQuery := "SELECT C1,C2,C3,C4,SALDO FROM TABELA
_cQuery := ChangeQuery(_cQuery)
TCQUERY _cQuery NEW ALIAS "TMP"
DbSelectArea("TMP")
DbGoTop()
While TMP->(!(EOF()))
//Carrega valores no aCols dentro do while
RecLock("TMP2", .F.)
TMP2->SALDO := 400
MSUnLock()
TMP->(Dbskip())
EndDo
TMP->(DbCloseArea())
I’m getting the bug TOP Error -19 - Invalid Operation - Update NOT ALLOWED on Query File.
when I try to update.
If you can’t post then you’ll have to turn around. One thing I can already tell, the documentation examples are all very bad. When I worked there, I made much simpler codes than these they teach you to do. I can’t help anymore either because this SQL thing isn’t from my day.
– Maniero
@bigown by the way, this mixture of SQL with function and with ->alias becomes a beautiful salad. It looks like a creation of Dr. Frankenstein. One of the most interesting things about xbase in general is the fact that you don’t need SQL, and it seems that people are going against each other, creating something with no identity. I abandoned the DB Riginals functions a long time ago in favor of SQL, but only for lack of a modern equivalent to Harbour (for now.
– Bacco
@Bacco but look at the bright side, it gives a lot of trouble and thus generates a huge amount of jobs. I have the impression that 90% of the people who work with Advpl would be unemployed or doing something else if it were made to work. The
dbSelectArea()
are there to make trouble. What I find most curious is the mixture of them with alias in each member :) When the technology provider uses wrong there is no way things will work out. You traded the RDD for the SQL, you didn’t keep them both, so yes.– Maniero
@Only one left moustache
SET FILTER
there to solve everything /s– Bacco
The error is self-explanatory: "TOP Error -19 - Invalid Operation - Update NOT ALLOWED on Query File." means that the application is trying to update a field of an ALIAS opened by a QUERY, which does not accept change via Advpl. A Query in Advpl is a read only and forward-only result-set.
– siga0984
For more information on how database access works in Advpl, I recommend reading the two posts below: Drivers and Rdds in Advpl And Data Access - Alias and Workarea in Advpl
– siga0984