Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 1 Jahr, 10 Monaten
Letzter Beitrag:
vor 1 Jahr, 10 Monaten
Beteiligte Autoren:
Michael Drechsel, Steven Sitas, Fabrice Harari, DarrenF

[WD20] HModify a Query result

Startbeitrag von Michael Drechsel am 26.07.2016 06:56

Hi,

I have the following constellation:

I have a query result which is then modified with "hmodify". After that I run a query from this (modified) query.
The results doesn´t include the changes which I made with hmodify.

Example:

Hexecutequery(MyQuery1)

for all myquery1
myquery1.myfield=today()
hmodify(myquery1)
end

Hexecutequery(MyQuery2_from_MyQuery1)

Any hints ?

Antworten:

Hi Michael,

It might depend on the complexity of your queries; i.e. if you have linked files for instance.

Not tried it, but I found this in the Help:
http://doc.windev.com/en-US/?3044234&name=Modifying_the_content_of_a_query

I'd be interested to know your findings because in my code I currently use HReadSeek... functions to re-read records I've retrieved via queries before I HModify them.

von DarrenF - am 26.07.2016 08:01
Hi Michael,
Assuming that the query comes from a database file, say myfile1, then you will have to use the following:

HexecuteQuery(MyQuery1, hModifyFile)

now you can use hmodify etc on MyQuery1 and it will affect your "base" file in the query.
This would be myfiles1.

When you rerun the query you will see the changes.
It is NOT always possible to MODIFY using the query - example queries with groups.

hModifyFile is ONLY needed for HFSQL files ...

Steven Sitas

von Steven Sitas - am 26.07.2016 08:12
Hi Steven, Darren,

I don´t want to modify the original dababase files.

I use Hmodify(myquery) to do something that I could not do in a query.

The Problem is shown below: The Filetoarray1 contains the modified values, the Filetoarray2 not ...
I believe that the execution of the 2nd Query reverses all changes made with Hmodify.

Hexecutequery(MyQuery1)

for all myquery1
myquery1.myfield=today()
hmodify(myquery1)
end

Filetoarray(myarray1,myquery1)

Hexecutequery(MyQuery2_from_MyQuery1)

Filetoarray(myarray2,myquery2)

von Michael Drechsel - am 26.07.2016 08:18
Hi Michael,
now I see what you are trying to do.
The second query is based on the first query ...

Do you have a table or something that is linked to the first query?
Maybe this thing (table, etc) RERUNs/REFRESHES your first query?

If you don't find a solution, a workaround would be to use a temporary HF file for the first file

Steven Sitas

von Steven Sitas - am 26.07.2016 08:52
No, its a stored procedure ....

von Michael Drechsel - am 26.07.2016 09:33
Hi Michael,

You are not showing us your code, so it' hard to be sure, but one possible culprit is hreadfirst.

You are saying "...The results doesn´t include the changes which I made with hmodify."

-IF- you are reading your query for whatever reason with hreadfirst and hreadfirst does not contain the option to prevent the RELOADING of the query, you may be executing your original query again at some point, AFTER the hmodifys

Best regards

von Fabrice Harari - am 26.07.2016 11:14
Hi Fabrice,

A query from a query should not execute the based query again ... or ?

If yes this could be the reason .... ok, I try to find a workaround.

von Michael Drechsel - am 26.07.2016 12:05
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.