spartacus
9th January 2003, 10:12
Hi all,
if I update a table in a report script, which is already selected in the program script. Is there any, an if, how is the influence to the selection which is done in the program script?
Thanks
Spartacus
ulrich.fuchs
9th January 2003, 11:55
I think this will depend on how the query in the program scripts operates.
In any case the program script should behave transactional for one single record. So, if you update the same record that was selected in the program script, the program script should not see that update.
However, I guess that scripts like
select *
db.retry.point()
from ... for update
order by ..._index1 with retry
selectdo
...
commit.transaction()
endselect
will have each record at the current state when it's processed between selectdo and endselect, not how it was when the query was sent to the database. So, if your report script modifies other records than the record currently selected by the script, the script will see the update.
However, this is just a guess, probably it's database driver dependent. But there is this "as prepared set" statement, which is documented as making the query read all the records of a query first and process them afterwards.
I think no general statement can be made on this issue. The behaviour will largely depend on how the script and report are programmed. (Is the commit done for every record, or for a number of records (every 50 ones...)?, is "prepared set" is used?, does the script use the 4GL select statements or the old db.* statements?, which records are updated by the report?, probably also: How does the database driver translates Baan SQL to database cursors and queries).
spartacus
9th January 2003, 15:34
Due to the fact, that we doesn't have the programscript I'm not able to see how the select is programmed there.
But I think things are not that complicated in our case, because I'm pretty sure, that the tabel I would like to update in report is not opened for update in the program script.
Based on what I would like to:
I would like to block every customer tccom010.cuno) with a dunning level > 2. Therefore I use a report of tfacr2421m000 session. The customer is already a input for the report (but I think it's opened just for reading). If there is any invoice for a given customer with dunning level > 2 I block this customer (tccom010.cnpa). Therefore I select tccom010 in the report for update (the same record as alredy should be selected in the program) call a db.update and immediatelly a
commit.transaction(). Maybe it is not a vey nice style, but it seems to work.
Spartacus
Dikkie Dik
9th January 2003, 16:18
As the report runs as another session (is another connection to the database) I don't know if it will work for all databases and circumstances. If the main session is doing an update on the same record this could conflict. If it works for Oracle, it probably works for all databases ;)
Kind regards,
Dick