Yes, you can do the execution in that manner. There are two possible ways to execute that kind of code:
1. Either you can set the database connection by allowing multiple queries, separated by a semi-colon by default.
2. Or you can call a stored procedure that will return the cursors implicitly.
For more information regarding the same, you can refer to the SQL training course.