I'm using SQLConnection
to database in repetitive ScheduledTask
. To prevent creation of new connections, and to maintain binding of connection to same symbol I made the following:
If[MatchQ[conn, _SQLConnection],
If[SQLConnectionOpenQ[conn],
If[(! SQLConnectionUsableQ[conn]), CloseSQLConnection[conn];
conn = OpenSQLConnection[conn];], conn = OpenSQLConnection[conn];],
conn = OpenSQLConnection["demo"];]
Question:
How to make the same procedure, but with usage of conn
symbol only on one place, NOT as above with conn
on 9 places?
EDIT: additionally to this question and to the answer below given by the Kuba, emerged new problem and question posted here SQLConnection causes kernel hangs