Oracle BLOB File(JAPANESE字符)插入表

时间:2017-04-27 02:35:18

标签: oracle plsql oracle11g character-encoding blob

我的blob文件包含日文字符。这是我的示例文本文件:

100100Œ©ÏˆË—Š•i”Ô•ªŠ„Žž‚Ì“®ìŠm”F

但在插入后我的表中只包含

100100¿¿¿¿¿¿¿i¿¿¿¿¿¿¿¿¿¿¿¿¿F

我如何在表格中与原始数据相同?

这是我的解析脚本

FUNCTION f_parse_brow (messages IN BLOB, st IN NUMBER, st_next OUT NUMBER) 
RETURN VARCHAR2 is

buffer_size   INTEGER          := 64000;
buffer        RAW (32676);
pattern       RAW (300)        := UTL_RAW.cast_to_raw (CHR (10));
v_temp        INTEGER;
var_buf       VARCHAR2 (32767);
st1           NUMBER;

begin
  v_temp := DBMS_LOB.INSTR (messages, pattern, st, 1);

 st1 := st;
 IF v_temp > 0
 THEN       
  buffer := DBMS_LOB.SUBSTR (messages, v_temp-st1, st1);
 ELSE        
  buffer := DBMS_LOB.SUBSTR (messages, buffer_size, st1);
 END IF;
 var_buf := UTL_RAW.cast_to_varchar2 (buffer);

 st_next := v_temp + 1;
 RETURN var_buf;
end f_parse_brow;

然后我将数据填充到表

Procedure p_populate_data(errbuf out varchar2,retcode out number,p_id in 
number,p_type in varchar2) is
--
l_lob                       BLOB;
str                         NUMBER            := 1;
str2                        NUMBER            := 2;
v_num                       NUMBER            := 1;
bvar_buf                    VARCHAR2 (32000);
bvar_buf2                   VARCHAR2 (32000);  
v_pcktab                    datatabtyp;
v_pckdatatab                bdatatabtyp;
--
vMESSAGE       VARCHAR2(3000);
V_PLAN_ID      NUMBER;
V_LENGTH       NUMBER;
VERR           VARCHAR2(500);  
--

BEGIN

select blob_content 
into l_lob
from GIIC_UPLOAD_FILE
where status='O'
and FILE_ID=p_id
AND FILE_NAME = P_TYPE;
--
--

WHILE str2 > 1
  LOOP
     bvar_buf := f_parse_brow (l_lob, str, str2);    


     IF (SUBSTR (bvar_buf, 1, 1) IS NOT NULL
         OR SUBSTR (bvar_buf, 1, 1) <> '')
     THEN
        SELECT length(BVAR_BUF) INTO V_LENGTH FROM DUAL;
        v_pcktab (v_num).data_file := bvar_buf;
        v_num := v_num + 1;

     ELSE
        EXIT;
     END IF;            
     str := str2;
  END LOOP; 



--
  v_num := 1;
--   
FOR i IN v_pcktab.FIRST .. v_pcktab.LAST
  LOOP

     VMESSAGE := RTRIM (SUBSTR (v_pcktab(i).data_file,
                             1,
                             V_LENGTH) 
                        );
             --       
     dbms_output.put_line(v_pcktab(i).data_file);

     v_pckdatatab (v_num).VMESSAGE          := v_pcktab(i).data_file;
     --
     v_num := v_num + 1;
  END LOOP;
  --
BEGIN
  --
  FOR s IN v_pckdatatab.FIRST .. v_pckdatatab.LAST
  LOOP
     IF v_pckdatatab(s).VMESSAGE IS NULL THEN
        null;
     ELSE

        select NPCS_HLFT_INV_REP_SEQ.NEXTVAL
        into v_PLAN_ID
        from dual;



       BEGIN
             INSERT INTO NPCS_HLFT_INV_REP--dev --to_trans4wdev
                           (FILE_ID,
                            FILE_TEXT,
                            GET_FLAG,
                            GET_DATE,
                            FILE_TYPE
                           )
                   VALUES (v_PLAN_ID,
                           v_pckdatatab (s).VMESSAGE,
                           '0',
                           SYSDATE,
                           p_type
                          );
              COMMIT;
           EXCEPTION WHEN OTHERS THEN
              NULL;
           END;

     END IF;
  END LOOP;
  --
  update GIIC_UPLOAD_FILE
  set status=1,
      lastupdate_TIMESTAMP=sysdate,
      lastupdate_by=1111
  where status='O'
  and FILE_id=p_id
  and FILE_NAME=p_type;
  commit;
  --
END;


end p_populate_data;    

0 个答案:

没有答案