CREATE OR REPLACE FUNCTION public.__agenda_04_add_comments_or_signature_to_student(
__p_id_student INTEGER,
__p_id_colaborator DATE,
__p_data JSONB)
RETURNS jsonb
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$
DECLARE
--CONSTANTES
__ERROR_ANP CONSTANT CHARACTER VARYING DEFAULT 'Acción no permitida';
__ERROR_NEE CONSTANT CHARACTER VARYING DEFAULT 'No existen estudiantes en este curso';
__ERROR_EA CONSTANT CHARACTER VARYING DEFAULT 'Se ingreso un array vacio';
__MSJ_ERROR CONSTANT CHARACTER VARYING DEFAULT 'Hubo un error';
__MSJ_SUCCESS CONSTANT CHARACTER VARYING DEFAULT 'Se actualizó';
__STATUS_500 CONSTANT INTEGER DEFAULT 500;
__STATUS_ERROR CONSTANT INTEGER DEFAULT 400;
__STATUS_SUCCESS CONSTANT INTEGER DEFAULT 200;
--VARIABLES
__result JSONB;
__result_json JSONB;
__msj_excep TEXT;
BEGIN
IF __p_id_student IS NULL THEN
RAISE EXCEPTION USING ERRCODE = 'SMILE', MESSAGE = __ERROR_NEE;
END IF;
IF __p_id_colaborator IS NULL THEN
RAISE EXCEPTION USING ERRCODE = 'SMILE', MESSAGE = __ERROR_ANP;
END IF;
IF __p_data = '[]' THEN
RAISE EXCEPTION USING ERRCODE = 'SMILE', MESSAGE = __ERROR_EA;
END IF;
---------------------------------
-------------- FIN --------------
__result = JSONB_BUILD_OBJECT('msj' , 'Ejecución correcta');
RETURN __result;
EXCEPTION
WHEN SQLSTATE 'SMILE' THEN
__result = JSONB_BUILD_OBJECT('status', __STATUS_ERROR , 'msj' , SQLERRM);
RETURN __result;
WHEN OTHERS THEN
GET STACKED DIAGNOSTICS __msj_excep = PG_EXCEPTION_CONTEXT;
__result = JSONB_BUILD_OBJECT('status', __STATUS_500, 'msj' , 'Hubo un error', 'stack_error', CONCAT(SQLERRM, ' - ', __msj_excep));
RETURN __result;
END;
$BODY$;
ALTER FUNCTION notas.__calificaciones_36__get_student_with_awards(integer, date, date)
OWNER TO postgres;
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.