Well, I think you should not ask about something else, but rather explain the situation you are in and ask for recommendations about which case should be used.
In any case, as everyone told you. In case 2, the connection object and its life cycle are encapsulated inside the function of the called subscriber. This is recommended if the database operating system does not support this feature.
Otherwise, if you have any other database activity that will be performed outside this functional area, for example, in the caller function or any other function (other than func) called from the caller function, then you should use Case 1.
source share