Skip to content

incendium.db.check

César Román edited this page Aug 11, 2021 · 14 revisions

Description

Execute a stored procedure against the connection.

This will return a flag set to TRUE or FALSE.

Syntax

incendium.db.check(stored_procedure, database, params)

Args:

  • stored_procedure (str): The name of the stored procedure to execute.
  • database (str): The name of the database connection to execute against. If omitted or "", the project's default database connection will be used. Optional.
  • params (dict): A Dictionary containing all parameters. Optional.

Returns:

  • bool: The flag.

Code Examples

import traceback

from incendium import constants, db, util
from java.lang import Exception as JException


def can_edit(id):
    flag = False

    try:
        params = {"id": [system.db.INTEGER, id]}
        flag = db.check("schema.stored_procedure", params)
    except JException as e:
        # system.db functions throw java.lang.Exception
        # Display error message using incendium.util.error.
        util.error(
            constants.UNEXPECTED_ERROR_CAUSED_BY.format(
                util.get_function_name(),  # Function's name.
                "\n".join(
                    traceback.format_exc().splitlines()
                ),  # Preserved traceback.
                e.cause,
            )
        )
    finally:
        return flag
Clone this wiki locally