Skip to content

incendium.db.check

César Román edited this page Apr 30, 2024 · 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 (list[InParam]): A list containing all INPUT parameters as InParam objects. Optional.

Returns:

  • bool: The flag.

Code Examples

import traceback

import system.db
from incendium import constants, db, util
from incendium.db import InParam
from incendium.vision import gui
from java.lang import Exception as JavaException


def can_edit(id_):
    flag = False

    try:
        params = [InParam("id", system.db.INTEGER, id_)]
        flag = db.check("schema.stored_procedure", params=params)
    except JavaException as exc:
        # system.db functions throw java.lang.Exception
        # Display error message using incendium.util.error.
        gui.error(
            constants.UNEXPECTED_ERROR_CAUSED_BY.format(
                util.get_function_name(),  # Function's name.
                "\n".join(traceback.format_exc().splitlines()),  # Preserved traceback.
                exc.cause,
            )
        )

    return flag
Clone this wiki locally