spartacus
28th July 2003, 18:43
I did the following:

- created a new text
- add this text as item text to an item (in Baan ERP)
- then I tried a text.delete(), to see, if it is possible to delete a text, which is in use. Used the following code:



|*** Function Call ***
diagnose = absstdll0010.delete.text(3272860)
message(str$(diagnose))
commit.transaction()



|*** The function in a DLL ***
function extern long absstdll0010.delete.text(domain tcmcs.long i.txt)
{
long ret

ret = -2

select tttxt001.*
from tttxt001
where tttxt001._index1 = {:i.txt}
selectdo
ret = text.delete("tttxt001.ctxt", "") |delete Text in all Langages
if ret >= 0 then
select absst230.*
from absst230 for update
where absst230._index2 = {:tttxt001.ctxt}
selectdo
db.delete(tabsst230, db.retry)
endselect
endif
endselect
return( ret )
}





This code retrurns me a "-1" what means error.
If I now open the text editor from the item maintenance, I see an empty text.
After closing the the text editor, just closing, do nothing, I can run my little programm and it returns a "0" what means success.

So "text.delete" deleted a text which is used. But more strange, it needs to tries to do that.

Between all that a checked the tables tttxt001, tttxt002 and tttxt010:
- after the first try to delete the text I found the textnumber deleted in tttxt002 and tttxt010.
- after I opend / closed the texteditor, tried my little programm the second time, also tttxt001 was empty.


Spartacus

NvanBeest
28th July 2003, 19:33
The text field in your table absst230 creates the reference to tttxt001. That's probably the reason why this record is not deleted immediately. Try the following sequence:


db.retry.point()
select absst320.*
from absst320 for update
where absst320._index2 = {:i.txt}
selectdo
db.delete(tabsst320, db.retry)
endselect
commit.transaction()

select tttxt001.*
from tttxt001
where tttxt001._index1 = {:i.txt}
selectdo
ret = text.delete("tttxt001.ctxt", "")
endselect
return( ret )

spartacus
28th July 2003, 20:44
Hi Nico

absst230 stores only a long just for textnumber. It is not a txtn domain or something.

But there is for sure a real referenz, because I added as item text. Sence of the test was to see, if text.delete() takes care about such things. But that seems not to be the case.

Spartaucs

NvanBeest
28th July 2003, 21:24
If the field in absst320 is a long only, there can be a possible logical reference, but if it is not declared as such in the database, then there is no "real" reference. Try to make the field a tctxtn field, and create the text with text.create("absst320.xxxx",...), and a physical reference will exist. Then deleting it from the text tables will probably work the way you want.

spartacus
29th July 2003, 11:03
absst230 contains no textfields. It is just a protokoll of used text -NUMBERS, and it shouldn't be a text field.

The problem occurs undependent from absst230 (I tried that to be sure)

The problem is, that text.delete() deletes used texts. Lets say a text is used in tcibd001.txta.
Then text.delete() returns a "-1", BUT in fact, after commmit.transaction() the text is deleted from tttxt010 and tttxt002. After you open the the in item maintenance and close again. You can use text.delete() once more, and now it returns "0", and also the text in tttxt001 is deleted.


Spartacus

OmeLuuk
31st July 2003, 11:08
Spartacus,

Could you update us on the progress of this problem? We got kind of interested...

I have seen some strange things happening with references on texts and text deletion in the past. Texts that were deleted when they were supposed to be used, texts that were not deleted in spite of them not being used, etc.

Would be nice to hear what you saw happening with the reference counter...

If you have a scenario where text records got cleared although used, you may want to run the scenario with -- -set DBSLOG=410 to see if the reference counters have the correct value:
Bind 13 : Refcntd : long : <0>
Bind 14 : Refcntu : long : <0>

We are looking forward.