DB Close
DB Close
Section titled “DB Close”Type: db-close · Package: Database Activities v1.0.3
Closes the connection to the database and releases its resources. It is the counterpart of DB Connect when you work without body (Option B of the session model).
How it works
Section titled “How it works”Closes the connection tied to the session. After that, the session can no longer be used: any later query with it fails. Open connections use resources on the database server, so close them as soon as you are done.
- If you don’t set
session, it closes the session of the enclosing DB Connectbody(not needed: thebodycloses it by itself). - Closing a session that was already closed does not raise an error.
Required parameters
Section titled “Required parameters”None.
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDbSession | — | The session returned by DB Connect. |
Output
Section titled “Output”This activity does not return a value.
Example
Section titled “Example”DB Connect provider = mysql connectionString = credential("db")["value"] → output: dbDB Query session = db sql = "SELECT * FROM products" → output: productsDB Close session = dbWrite Excel Sheet path = "C:\Reports\products.xlsx" data = productsCommon errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'session' is required and must be a database session. | No session was passed (or the variable holds no session) and the activity is not inside a DB Connect body. |
Related activities
Section titled “Related activities”- DB Connect — open the connection.
- Try / Catch — close in the
finallyso no connections stay open.