Unanswered: checking if a database can be dropped/renamed/exported
Hi, I have searched for this question, could not find a similar question.
I need to do an overnight rename of a DB but occasionally the rename fails with the message
425: Database is currently opened by another user.
107: ISAM error: record is locked.
Is there a simple way to check from the script before I execute the rename if the DB is locked ?
I guess the answer is onstat -g ses and then check each session and check the "Current Database field".
However, the output of onstat -g ses <sid> is not the most friendly to parse, is there an alternative or an option to format the output of onstat to be more easily parsed or could I execute a query equivalent to onstat -g ses ?
thanks a lot, I eventually found out about onstat -g sql to extract all sessions for a specific DB and then check them with onstat -g sess <sessionid>.
I am not allowed to kill them so all I can do is detect the sessions and wait until they go away for a timeout period.
One thing I discovered is that the session was an update statistics executed automatically by AUS.
Unfortunately I am not the DBA, but I have to write these scripts with a lot of limitations on what I can do based on the DBAs guidelines.
Thanks a lot for your reply and code.