As the title suggests, I'm trying to figure out how to write some code which checks whether a table is locked, and if it is, then use a backup table.
The situation is as follows:
Every day a table (Table A)is updated and locked in the process. This takes a few hours.
During that time, several people will want to use that locked table, so I make a daily backup stored in a second location (Table B).
I would like some code which checks the lock status of A and either uses it, or redirects the rest of the code to use B in the case A is locked.
Thanks in advance
(SAS Enterprise Guide 7.13 HF8)
A better approach would be for users to always use the backup copy and to copy to the backup as soon as the update of the primary table is complete. If this copy from primary to backup takes less than 10 minutes then you can use the FILELOCKWAIT SAS option on all LIBNAME allocations for this table to take care of any file locking issues. FILELOCKWAIT will only wait for a maximum of 10 minutes:
One way is as follows:
Users use the following libname statement:
libname TABLES ( 'c:\tables_being_replaced' 'c:\perm_tables' ) access=readonly;
The first folder is always empty.
When you want to replace a table, move it to the first folder and build the replacement in the second folder.
Delete the old table when done.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.