Skip to content

incendium.db.o_get_data

César Román edited this page Apr 30, 2024 · 10 revisions

Description

Get data and OUTPUT parameters by executing a stored procedure.

Syntax

incendium.db.o_get_data(stored_procedure, out_params, [database], [in_params])

Args:

  • stored_procedure (str): The name of the stored procedure to call.
  • out_params (list[OutParam]): A list containing all OUTPUT parameters as OutParam objects.
  • database (str): The name of the database connection to execute against. If omitted or "", the project's default database connection will be used. Optional.
  • in_params (list[InParam]): A list containing all INPUT parameters as InParam objects. Optional.

Returns:

  • tuple: A tuple containing a Dataset that is the resulting data of the stored procedure call, if any, and a Python dictionary of OUTPUT parameters.

Recommendations

None.

Code Examples

Passing parameters.

from __future__ import print_function

import system.db
from incendium import db
from incendium.db import InParam, OutParam
from java.lang import Exception as JavaException


def get(int_param):
    """Get a row from the database."""
    try:
        in_params = [InParam("int_param", system.db.INTEGER, int_param)]
        out_params = [OutParam("out_int_param", system.db.INTEGER)]
        # TODO: Do something with the result_set and output_params
        # returned by o_get_data
        return db.o_get_data("schema.stored_procedure", out_params, in_params=in_params)
    except JavaException as exc:
        # system.db functions throw java.lang.Exception
        # TODO: Handle exception.
        print(repr(exc))

Passing no INPUT parameters.

from __future__ import print_function

import system.db
from incendium import db
from incendium.db import OutParam
from java.lang import Exception as JavaException


def get_all():
    """Get multiple rows of data from the database."""
    data = None

    try:
        out_params = [OutParam("out_int_param", system.db.INTEGER)]
        # TODO: Do something with the result_set and output_params
        # returned by o_execute_non_query
        data = db.o_get_data("schema.stored_procedure", out_params)
    except JavaException as exc:  # system.db functions throw java.lang.Exception
        # TODO: Handle exception.
        print(repr(exc))

    return data
Clone this wiki locally