固定长度文件读入:
-------------------------------------------------------------------
-- 共通固定長ファイル区切り関数
-- 機能: 固定長ファイル区切り取得
-- 引数: PV2_STRING IN VARCHAR2 処理フィールド
-- PNU_POS_BEGIN IN NUMBER 開始位置
-- PNU_POS_LEN IN NUMBER 桁数
-- 戻り値:VARCHAR2 処理結果
-------------------------------------------------------------------
FUNCTION FNC_GET_SUBSTR(
PV2_STRING IN VARCHAR2,
PNU_POS_BEGIN IN NUMBER,
PNU_POS_LEN IN NUMBER
)
RETURN VARCHAR2
IS
BEGIN
IF PNU_POS_BEGIN >0 AND PNU_POS_LEN > 0 THEN
IF LENGTH(PV2_STRING) > PNU_POS_BEGIN + PNU_POS_LEN - 1 THEN
RETURN TRIM(SUBSTRB(PV2_STRING,PNU_POS_BEGIN,PNU_POS_LEN));
ELSE
RETURN GCV2_NULL;
END IF;
ELSE
RETURN GCV2_NULL;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN GCV2_NULL;
END FNC_GET_SUBSTR;
变长,CSV,TAB等文件读入
-------------------------------------------------------------------
-- 共通可変長タブ区切り関数
-- 機能: 可変長タブ区切り取得
-- 引数: PV2_STRING IN VARCHAR2 処理フィールド
-- PNU_POSITION IN NUMBER 項目位置
-- PV2_SEPARATE IN VARCHAR2 可変長タブ
-- 戻り値:VARCHAR2 処理結果
-------------------------------------------------------------------
FUNCTION FNC_GET_POSSTR(
PV2_STRING IN VARCHAR2,
PNU_POSITION IN NUMBER,
PV2_SEPARATE IN VARCHAR2
)
RETURN VARCHAR2
IS
WNU_POS_BEGIN NUMBER;
WNU_POS_END NUMBER;
BEGIN
IF PNU_POSITION = 1 THEN
WNU_POS_BEGIN := 1;
IF INSTRB(PV2_STRING,PV2_SEPARATE,1,1) = 0 THEN
RETURN GCV2_NULL;
ELSE
WNU_POS_END := INSTRB(PV2_STRING,PV2_SEPARATE,1,1);
END IF;
ELSIF PNU_POSITION > 0 THEN
IF INSTRB(PV2_STRING,PV2_SEPARATE,1,PNU_POSITION) = 0 THEN
IF INSTRB(PV2_STRING,PV2_SEPARATE,1,PNU_POSITION-1) = 0 THEN
RETURN GCV2_NULL;
ELSE
WNU_POS_BEGIN := INSTRB(PV2_STRING,PV2_SEPARATE,1,PNU_POSITION-1) + 1;
WNU_POS_END := LENGTH(PV2_STRING);
END IF;
ELSE
WNU_POS_BEGIN := INSTRB(PV2_STRING,PV2_SEPARATE,1,PNU_POSITION-1) + 1;
WNU_POS_END := INSTRB(PV2_STRING,PV2_SEPARATE,1,PNU_POSITION);
END IF;
ELSE
RETURN GCV2_NULL;
END IF;
RETURN TRIM(SUBSTRB(PV2_STRING,WNU_POS_BEGIN,WNU_POS_END - WNU_POS_BEGIN -1));
EXCEPTION
WHEN OTHERS THEN
RETURN GCV2_NULL;
END FNC_GET_POSSTR;
本文地址:http://com.8s8s.com/it/it19616.htm