This little procedure's been floating around for years and years, and the source code sits in various inaccessible places like the NNTP newsgroups, the execrable CodeXchange and a sub-sub-sub-folder on my C drive called "miscellaneous".
Time to put it somewhere accessible: Google.
As in, "on an actual web page".
As in, here...
How to get full control over a SQL Anywhere server
1 | <br>CREATE PROCEDURE p_drop_other_connections ()<br>BEGIN<br><br>/* How to get full control over a SQL Anywhere server...<br><br>(1) CALL sa_server_option ( 'ConnsDisabled', 'ON' );<br><br> At this point, any attempt to open a new connection will<br> get "Connections to database have been disabled". <br> However, current connections will still work until...<br><br>(2) CALL p_drop_other_connections(); <br><br>(3) Do whatever you need to do.<br><br>(4) CALL sa_server_option ( 'ConnsDisabled', 'OFF' );<br><br>*/<br><br>DECLARE @this_connection_id INTEGER;<br>DECLARE @other_connection_id INTEGER;<br>DECLARE @drop_command VARCHAR ( 1000 );<br><br>SET @this_connection_id = connection_property ( 'number' );<br>SET @other_connection_id = NEXT_CONNECTION ( NULL );<br><br>WHILE @other_connection_id IS NOT NULL LOOP<br><br> IF @other_connection_id <> @this_connection_id THEN<br> SET @drop_command = STRING ( <br> 'DROP CONNECTION ', <br> @other_connection_id );<br> EXECUTE IMMEDIATE @drop_command;<br> END IF;<br><br> SET @other_connection_id <br> = NEXT_CONNECTION ( @other_connection_id ) <br><br>END LOOP;<br><br>END;<br> |
No comments:
Post a Comment