2010-02-04 4 views
2

ASP.NET appliaction에서 SQLloader를 사용하여 CSV/EXCEL에서 Oracle DB로 대량 업로드 데이터를 자동화하고 있습니다. Sqlloader는 서버에서 생성 된 가져 오기 결과를 보여주는 로그 파일을 생성합니다.sql 로더 로그 파일 결과

내 사용자에게 정보를 표시하겠습니다.

얼마나 많은 행이 읽습니까? 얼마나 많이 성공적으로 가져 왔습니까? aspx 페이지에

어떻게하면됩니까?

답변

4

외부 테이블을 만들어 로그 파일을 읽을 수 있습니다. 이 덕분에 외부 테이블을 SQL 쿼리에 사용할 수 있습니다.

먼저 OS 디렉토리 경로를 식별하기 위해 디렉토리 객체를 만들어야합니다. 이것은 우리가 테이블을 생성

SQL> create or replace directory sqlldr_log_dir as 'C:\your\directory\path' 
    2/

Directory created. 


SQL> grant read , write on directory sqlldr_log_dir to apc 
    2/

Grant succeeded. 

SQL> 

다음 .... CREATE ANY DIRECTORY 권한 (아마 DBA 계정)을 가진 사용자에 의해 수행 될 필요가있다.

C:\temp>imp apc file=apc_20100204.dmp log=apc_20100204.log tables=PTEST6,A 

Import: Release 11.1.0.6.0 - Production on Thu Feb 4 11:51:07 2010 

Copyright (c) 1982, 2007, Oracle. All rights reserved. 

Password: 

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

Export file created by EXPORT:V11.01.00 via conventional path 
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set 
. importing APC's objects into APC 
. importing APC's objects into APC 
. . importing table       "A"   12 rows imported 
. . importing table      "PTEST6"   19 rows imported 
IMP-00009: abnormal end of export file 
Import terminated successfully with warnings. 

C:\temp> 

이 디렉토리가 사용한 것과 같은 diectory해야 ... 가져 오기를 수행하는 .... 위치 절에서 로그 파일의 OS 밖으로 지금

SQL> create table sqlldr_logfiles (
    2  text_line varchar2(1024) 
    3 ) 
    4 organization external 
    5 (
    6  type oracle_loader 
    7  default directory sqlldr_log_dir 
    8  access parameters 
    9   (records delimited by newline 
10    fields (text_line char(1024) 
11   ) 
12  ) 
13  location ('changeme.log') 
14 ) 
15/

Table created. 

SQL> 

을 자리 표시 자 이름을 참고 전에. SQL로 돌아 가기. 먼저 우리는 출력을 포맷하면 당신이 10g 이상이, 그래서 정규식 기능을 사용할 수 있습니다 특히, 쉽게 우리가 이전에 사용하고 그것에서 쿼리 로그 파일에서 외부 테이블 ...

SQL> alter table sqlldr_logfiles location ('apc_20100204.log') 
    2/

Table altered. 

SQL> select * from sqlldr_logfiles 
    2 where text_Line like '. . importing table%' 
    3/

text_Line 
-------------------------------------------------------------------------------- 
. . importing table       "A"   12 rows imported 
. . importing table      "PTEST6"   19 rows imported 

SQL> 

을 가리 킵니다.

+0

+1 멋진 미니 튜토리얼입니다. – DCookie