create or replace package bsys.sys_get_api
is
-- 고정변수 정의
c_package_name constant varchar2(0200) default 'sys_get_api';
-- 함수 정의
function dft_lang_cd_f return varchar2;
function dft_corp_id_f return number;
function code_name_f
(pi_code_type_cd in varchar2 -- 코드유형
,pi_code in varchar2 -- 코드
) return varchar2;
function emp_name_f
(pi_emp_id in number -- 임직원id
) return varchar2;
function corp_name_f
(pi_corp_id in number -- 법인id
) return varchar2;
function biz_name_f
(pi_biz_id in number -- 사업장id
) return varchar2;
function dept_id_f
(pi_dept_cd in varchar2 -- 부서코드
) return number;
function postal_code_f
(pi_postal_id in number -- 우편번호id
) return varchar2;
function road_address_f
(pi_postal_id in number -- 우편번호id
) return varchar2;
end sys_get_api;
create or replace package body bsys.sys_get_api
/* ********************************************************************************************
* 업 무 단 위 : 시스템관리
* 패 키 지 : bsys.sys_get_api
* 사 용 목 적 : 업무코드 및 명칭 조회 패키지
* 스크립트명칭 : 시스템관리_패키지_명칭조회_생성
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
--------------------------------------------------------------------------------------------
* 수정일자 수정자 수정내역
--------------------------------------------------------------------------------------------
* 2024-02-01 Admin 최초 작성
******************************************************************************************** */
is
/* ********************************************************************************************
* 사 용 목 적 : 프로파일 언어코드 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function dft_lang_cd_f return varchar2
is
l_result_value varchar2(200) default null;
begin
-- 언어코드 조회
begin
select sp.profile_value
into l_result_value
from sys_profile sp
where 1 = 1
and sp.profile_cd = upper('lang_cd')
and sp.corp_id = sys_env_f('corp_id')
and trunc(sysdate) between sp.start_date and nvl(sp.end_date, trunc(sysdate));
exception
when others then
l_result_value := sys_init_api.c_lang_cd;
end;
-- 리턴
return l_result_value;
end dft_lang_cd_f;
/* ********************************************************************************************
* 사 용 목 적 : 프로파일 법인id 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function dft_corp_id_f return number
is
l_result_value varchar2(200) default null;
begin
-- 법인id 조회
begin
select to_number(sp.profile_value)
into l_result_value
from sys_profile sp
where 1 = 1
and sp.profile_cd = upper('corp_id')
and trunc(sysdate) between sp.start_date and nvl(sp.end_date, trunc(sysdate));
exception
when others then
l_result_value := sys_init_api.c_num_null;
end;
-- 리턴
return l_result_value;
end dft_corp_id_f;
/* ********************************************************************************************
* 사 용 목 적 : 코드명칭 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function code_name_f
(pi_code_type_cd in varchar2 -- 코드유형
,pi_code in varchar2 -- 코드
) return varchar2
is
l_return_value varchar2(200) default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_code_type_cd is null or pi_code is null then
return sys_init_api.c_char_null;
end if;
-- 코드에 대한 명칭 조회
begin
select cc.code_name
into l_return_value
from com_code cc
where 1 = 1
and cc.code = upper(pi_code)
and exists (
select 1
from com_code_type cct
where 1 = 1
and cct.corp_id = sys_env_f('corp_id')
and cct.code_type_cd = upper(pi_code_type_cd)
and cct.code_type_id = cc.code_type_id
);
exception
when others then
l_return_value := sys_init_api.c_char_null;
end;
-- 리턴
return l_return_value;
end code_name_f;
/* ********************************************************************************************
* 사 용 목 적 : 직원성명 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function emp_name_f
(pi_emp_id in number -- 임직원id
) return varchar2
is
l_return_value varchar2(200) default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_emp_id is null then
return sys_init_api.c_char_null;
end if;
-- 임직원 성명 조회
begin
select he.emp_name
into l_return_value
from hrm_employee he
where 1 = 1
and he.emp_id = pi_emp_id;
exception
when others then
l_return_value := sys_init_api.c_char_null;
end;
-- 리턴
return l_return_value;
end emp_name_f;
/* ********************************************************************************************
* 사 용 목 적 : 법인명 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function corp_name_f
(pi_corp_id in number -- 법인id
) return varchar2
is
l_return_value varchar2(200) default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_corp_id is null then
return sys_init_api.c_char_null;
end if;
-- 법인명 조회
begin
select hc.corp_name
into l_return_value
from hrm_corporation hc
where 1 = 1
and hc.corp_id = pi_corp_id;
exception
when others then
l_return_value := sys_init_api.c_char_null;
end;
-- 리턴
return l_return_value;
end corp_name_f;
/* ********************************************************************************************
* 사 용 목 적 : 사업장명 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function biz_name_f
(pi_biz_id in number -- 사업장id
) return varchar2
is
l_return_value varchar2(200) default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_biz_id is null then
return sys_init_api.c_char_null;
end if;
-- 사업장명 조회
begin
select hbp.biz_name
into l_return_value
from hrm_business_place hbp
where 1 = 1
and hbp.biz_id = pi_biz_id;
exception
when others then
l_return_value := sys_init_api.c_char_null;
end;
-- 리턴
return l_return_value;
end biz_name_f;
/* ********************************************************************************************
* 사 용 목 적 : 부서id 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function dept_id_f
(pi_dept_cd in varchar2 -- 부서코드
) return number
is
l_return_value number default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_dept_cd is null then
return sys_init_api.c_num_null;
end if;
-- 부서id 조회
begin
select hd.dept_id
into l_return_value
from hrm_dept hd
where 1 = 1
and hd.dept_cd = upper(pi_dept_cd);
exception
when others then
l_return_value := sys_init_api.c_num_null;
end;
-- 리턴
return l_return_value;
end dept_id_f;
/* ********************************************************************************************
* 사 용 목 적 : 우편번호 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function postal_code_f
(pi_postal_id in number -- 우편번호id
) return varchar2
is
l_return_value varchar2(10) default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_postal_id is null then
return sys_init_api.c_char_null;
end if;
-- 사업장명 조회
begin
select spc.postal_cd
into l_return_value
from sys_postal_code spc
where 1 = 1
and spc.postal_id = pi_postal_id;
exception
when others then
l_return_value := sys_init_api.c_char_null;
end;
-- 리턴
return l_return_value;
end postal_code_f;
/* ********************************************************************************************
* 사 용 목 적 : 도로명주소 조회 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function road_address_f
(pi_postal_id in number -- 우편번호id
) return varchar2
is
l_return_value varchar2(500) default null;
l_user_exception exception;
begin
-- 변수값 검증
if pi_postal_id is null then
return sys_init_api.c_char_null;
end if;
-- 사업장명 조회
begin
select nvl2(spc.sido, spc.sido, '')
|| nvl2(spc.sigungu , ' ' || spc.sigungu , '')
|| nvl2(spc.road_name , ' ' || spc.road_name , '')
|| nvl2(spc.building_num_main , ' ' || spc.building_num_main , '')
|| nvl2(spc.building_sigungu_name, ' ' || spc.building_sigungu_name, '') as road_address
into l_return_value
from sys_postal_code spc
where 1 = 1
and spc.postal_id = pi_postal_id;
exception
when others then
l_return_value := sys_init_api.c_char_null;
end;
-- 리턴
return l_return_value;
end road_address_f;
end sys_get_api;
'오라클 > 패키지(시스템공통)' 카테고리의 다른 글
[ 로그생성 ] sys_log_api 패키지를 생성합니다. (0) | 2024.04.12 |
---|---|
[ 환경설정 ] sys_env_api 패키지를 생성합니다. (0) | 2024.04.12 |
[ 세션정보 ] sys_env_f 함수를 생성합니다. (0) | 2024.04.12 |
[ 데이터검증 ] sys_valid_api 패키지를 생성합니다. (0) | 2024.04.04 |
[ 전역변수 및 메시지 출력 ] sys_init_api 패키지를 생성합니다. (0) | 2024.04.04 |