When i need to return a cursor using REST i have to use a command similar to this ADDPROPERTY(loResult,"data","cursor:crTemp") In this case i'll have in my response a tag called "Data" where i have all fields and their content..... Obviously i need to have my table still opened when i have the Return loResult command in my code After this command all is in the hands of your class.... The problem is that i need to close the cursor i used. Is there a place where i can close this table after you have created the response ? If i close the table before the Return loResult command i don't receive anything in the Data tag, if i leave the table opened i receive all the data, but when i make a new call to the REST i have problems because the table is still opened and even if the alias is the same in the new request the source can be different, because i need another records, or simply the same table but from a different db.... I hope to explained the problem, but it is not a simple problem.... i think
Thanks
Generally I would recommend leaving tables and cursors open as new queries to the same name will just overwrite the data. If you're consistent with your cursor names and you commonly write the same cursors, then closing really doesn't provide much benefit.
That said, for Services you can implement OnProcessComplete()
in your wwRestProcess/wwProcess class which fires after requests are completed. This fires for all of them.
FUNCTION OnProcessComplete()
IF USED("MyLargeCursor")
USE in MyLargeCursor
ENDIF
IF USED("MyOtherLargeCursor")
USE IN MyOtherLargeCursor
ENDIF
ENDFUNC
Since this is global this can get pretty bulky, but as I said if you're consistent with cursor naming and you reuse cursor names via generic query names (I like to use TQuery/1/2/3 etc.) then you only ever end up with a certain number of cursors anyway and you can leave them open or close them in OnProcessComplete()
.
+++ Rick ---
The problem is that my rest works on different companies at the same time. Different companies means different databases, but with the same tables name. So the same rest function can work on the same alias (for example cranag) but from different dB and I can't risk to use the same table, apparently, but from different databases. So I prefer to close the table (cursor adapter in my case) at the end of each request and reopen it with different connection when a new similar request arrives.
In that case, have you considered using DataSessions and then just closing the data session at the end of the request?
In your case it may be as easy as just doing a close all except
though (keep open a few of the support tables/cursors - check SET
value in Unload to see what's still open other than your own applications files).
+++ Rick ---