-
-
Notifications
You must be signed in to change notification settings - Fork 2
incendium.db.get_return_value
César Román edited this page Apr 30, 2024
·
14 revisions
Get the Return Value from the Stored Procedure.
incendium.db.get_return_value(stored_procedure, return_type_code, [database], [transaction], [params])
Args:
- stored_procedure (
str
): The name of the stored procedure to execute. - return_type_code (
int
): The Type Code of the Return Value. - database (
str
): The name of the database connection to execute against. If omitted or "", the project's default database connection will be used. Optional. - transaction (
str
): A transaction identifier. If omitted, the call will be executed in its own transaction. Optional. - params (
list
[InParam
]): A list containing all INPUT parameters as InParam objects. Optional.
Returns:
- int: The return value.
For Microsoft SQL Server, the return type is INT
. See: Return Types, and
Returning status codes.
from __future__ import print_function
import system.db
from incendium import db
from incendium.db import InParam
from java.lang import Exception as JavaException
# Stored procedure:
# USE AdventureWorks2012;
# GO
# CREATE PROCEDURE dbo.checkstate @param varchar(11)
# AS
# IF (
# SELECT StateProvince
# FROM Person.vAdditionalContactInfo
# WHERE ContactID = @param
# ) = 'WA'
# RETURN 1
# ELSE
# RETURN 2;
# GO
def check_state():
try:
# Initialize INPUT parameters.
params = [InParam("param", system.db.VARCHAR, "WA")]
return db.get_return_value(
"dbo.checkstate", return_type_code=system.db.INTEGER, params=params
)
except JavaException as exc:
# system.db functions throw java.lang.Exception
# TODO: Handle exception.
print(repr(exc))