Skip to content

incendium.db.check

Cesar Roman edited this page Sep 23, 2020 · 14 revisions

Description

Executes a stored procedure that returns 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
  • 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

# Imports.
import traceback

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

def can_edit(id):
    # Initialize variables.
    flag = False

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