2008-09-23 5 views

답변

15

PL/SQL에서 전체적으로 수행하려면 파일을 데이터베이스에 정의해야하는 디렉토리에 위치시켜야합니다. 다음 개체를 만듭니다.

+0

보고서 서버 (하이퍼 링크)에서 파일을 읽고 여기 BLOB 개체에 파일을 추가하는 방법을 알려주십시오. http://stackoverflow.com/questions/26881146/how-to-load-a-file-from-a-hyperlink-to-blob – Amir

+0

안녕하세요,이 테이블에 파일을 추가하지 않고도 할 수 있습니까? –

0

환경에 따라 약간 다름. 자바에서는 다음과 같이 할 수 있습니다.

// Need as OracleConnection in mConnection 

// Set an EMPTY_BLOB() 
String update = "UPDATE tablename"+ 
       " SET blob_column = EMPTY_BLOB()"+ 
       " WHERE ID = "+id; 
CallableStatement stmt = mConnection.prepareCall(update); 
stmt.executeUpdate(); 

// Lock the row FOR UPDATE 
String select = "BEGIN " + 
         " SELECT " + blob_column 
         " INTO ? " + 
         " FROM " + tablename + 
         " WHERE ID = '" + id + "'" + 
         " FOR UPDATE; " + 
         "END;"; 

stmt = mConnection.prepareCall(select); 
stmt.registerOutParameter(1, java.sql.Types.BLOB); 
stmt.executeUpdate(); 

BLOB blob = (BLOB) stmt.getBlob(1); 
OutputStream bos = blob.setBinaryStream(0L); 
FileInputStream fis = new FileInputStream(file); 
// Code needed here to copy one stream to the other 
fis.close(); 
bos.close(); 
stmt.close(); 

mConnection.commit(); 

하지만 실제로 사용하는 환경/도구에 따라 다릅니다. 더 많은 정보가 필요합니다.

관련 문제