BFILE Problem

Hello,
The problem that i have is that i want to insert a file residing in the network into the oracle database into a blob field and again read it from the database and show it ie either insert it into a file directly and then open it using the correct editor or open it directly. I am using java along with it but i am basically stuck on the database side.
I am sending the code which i have written till date
i basically need to know
1)the syntax i am using to interact with the database is right ie where is the error in the code
2)provided that is ok whether my overall code is on the right track.
After line control 10
The error message i am getting:
java.sql.SQL Exception:ORA-22288:file operation fileopen failed
LFI:00108:open expect the file[map][gif] to exist
ORA-0615:at"SYS.DBMS_LOB",line 370
ORA-0615:at line 1
My developopment enviornment is JDeveloper3.0 as this code is having problems compiling in JDK as Jdeveloper overides a few of the jdk classes.
=========================================================================
My table structure
CREATE TABLE DOC_MAS(
DOC_MAS_SR_NO NUMBER(10),
PROJECT_NAME VARCHAR2(30),
MODULE_NO NUMBER(10),
DOC_NAME VARCHAR2(10),
DOC_TYPE VARCHAR2(10),
VERSION NUMBER(10));
CREATE SEQUENCE SEQ_DOC_MAS START WITH 1 INCREMENT BY 1;
CREATE SEQUENCE SEQ_DOC_DETAIL START WITH 1 INCREMENT BY 1;
CREATE TABLE DOC_DETAIL(
DOC_DETAIL_SR_NO NUMBER(10),
DOC_MAS_SR_NO NUMBER(10),
DATE_OF_INSERT DATE,
ACTUAL_DOC BFILE,
COMMENTS VARCHAR2(500));
===============================================================================
My connection code:
public class ConnectionParams {
// The machine on which the database resides
//public final static String s_hostName = "insn110a.in.oracle.com";
public final static String s_hostName = "192.168.1.1";
// The TNS listener port
public final static String s_portNumber = "1521";
// The database name (SID)
//public final static String s_databaseSID = "otndb";
public final static String s_databaseSID = "orcl";
// The database User ID
public final static String s_userName = "scott";
// The database user password
public final static String s_password = "tiger";
========================================================================================
import java.io.*;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
import java.util.*;
import java.util.Date;
//import java.math.BigDecimal;
public class Sample3
int size;
Connection m_connection; //Database Connection Object
String p_doc_name=null;
String s_blobvariable = p_doc_name;
String file_path = null;
byte b[];
String l_dirPath;
public Sample3()
dbConnection();
public static void main(String[] args)
Sample3 lobs = new Sample3();
// lobs.dbConnection();
lobs.readFileNameExt();
/*This class is for creation of connection =========================================*/
public void dbConnection() {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String l_dbConnectString =
"(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
"(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
"(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
m_connection = DriverManager.getConnection(
"jdbc:oracle:thin:@"+l_dbConnectString,
ConnectionParams.s_userName, ConnectionParams.s_password);
m_connection.setAutoCommit(false);
System.out.println("Connection Successful");
Thread.sleep(3000);
} catch(Exception ex){ //Trap SQL errors
System.out.println("Error in Connecting to the Database "+ex.toString());
/*========================================================================================
File inserting section of the code
// THIS class gets the input from the file dialog box it gets the file path,projectName and the module no
//public void readFileNameExt(String p_doc_path,String p_module_no,String p_project_name)
public void readFileNameExt()
String p_doc_path = "c:/warea/Mehul2/map.gif";
int p_module_no = 10;
String p_project_name = "Finserve";
String p_doc_type= null;
String p_version = null;
StringTokenizer strtkn = new StringTokenizer(p_doc_path,"/");
while(strtkn.hasMoreTokens())
p_doc_name =strtkn.nextToken();
System.out.println("The file name is" +p_doc_name);
s_blobvariable = p_doc_path;
StringTokenizer strtoken = new StringTokenizer(p_doc_name,".");
while(strtoken.hasMoreTokens())
p_doc_type =strtoken.nextToken();
try{
System.out.println("The file Type is"+p_doc_type);
insertDocMas(p_doc_path,p_doc_name,p_doc_type,p_project_name,p_module_no);
Thread.sleep(10000);
}catch (Exception e){}
}//end of method
//============================================== this class is for inserting the doc_mas details in teh table along with version checking
public void insertDocMas(String p_doc_path,String p_doc_name,String p_doc_type,String p_project_name,int p_module_no){
int p_version = -1;
int p_doc_mas_sr_no = -1;
// String verision=null;
int verision;
String s = null;
try{
Statement l_stmt = m_connection.createStatement();
ResultSet l_version_details = l_stmt.executeQuery("SELECT MAX(VERSION) FROM DOC_MAS WHERE DOC_NAME = '"+p_doc_name+"'");
if (l_version_details.next())
{ System.out.println("The Control 1");
verision = l_version_details.getInt(1);
System.out.println("The Control 2 : "+verision);
verision = verision +1;
else {
verision = 1;
System.out.println("The Control 3");
p_version = verision;
// System.out.println("The value of p_version" + p_version);
l_version_details.close();
l_stmt.close();
Thread.sleep(4000);
}catch(Exception e){
System.out.println("Exception has occured at the time of insert"+e);
System.out.println("The value of p_version" + p_version);
/* try{
Statement stmt = m_connection.createStatement();
ResultSet rset = stmt.executeQuery("select DEPTNO,DNAME,LOC from DEPT");
while(rset.next()){
BigDecimal deptno = rset.getBigDecimal(1,2);
String dname = rset.getString(2);
// Timestamp hiredate = rset.getTimestamp(3);
String loc = rset.getString(3);
System.out.println(deptno+" "+dname+" "+loc);
Thread.sleep(50000);
}catch(Exception e){System.out.println(e);}
try{
Statement l_stmt = m_connection.createStatement();
ResultSet l_seq_details = l_stmt.executeQuery("SELECT SEQ_DOC_MAS.NEXTVAL FROM DUAL");
if (l_seq_details.next())
p_doc_mas_sr_no = l_seq_details.getInt(1);
System.out.println("The Control AA");
System.out.println("The value of p_doc_mas_sr_no" + p_doc_mas_sr_no);
l_seq_details.close();
l_stmt.close();
Thread.sleep(4000);
}catch(Exception e){
System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
try {
System.out.println("Creating rows in DOC_MAS.. ");
System.out.println("The Control VV");
PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_MAS(DOC_MAS_SR_NO,PROJECT_NAME,MODULE_NO,DOC_NAME,DOC_TYPE,VERSION) values(?,?,?,?,?,?)");//SEQ_DOC_MAS.nextval
l_pstmt.setInt(1,p_doc_mas_sr_no);//"SEQ_DOC_DETAIL.NEXTVAL"
l_pstmt.setString(2,p_project_name);
l_pstmt.setInt(3,p_module_no);
l_pstmt.setString(4,p_doc_name);
l_pstmt.setString(5,p_doc_type);
l_pstmt.setInt(6,p_version);
l_pstmt.executeUpdate(); // Execute SQL statement
l_pstmt.close();
System.out.println("The Control 3");
// Close statement
//Thread.sleep(20000);
}catch(Exception e){
System.out.println("Exception has occured at the time of insert11"+e);
try{System.out.println("The Control 4");
Statement l_statement = m_connection.createStatement();
ResultSet l_doc_mas_sr_no = l_statement.executeQuery(
"SELECT max(DOC_MAS_SR_NO) FROM DOC_MAS "+
"WHERE DOC_NAME = '"+p_doc_name+"' ");//FOR UPDATE
if (l_doc_mas_sr_no.next())
p_doc_mas_sr_no = l_doc_mas_sr_no.getInt(1);
l_doc_mas_sr_no.close();
l_statement.close();
System.out.println("The Control 5");
//Thread.sleep(10000);
}catch(Exception e){
System.out.println("Exception has occured at the time of insert");
loadSamples(p_version,p_doc_path,p_project_name,p_doc_mas_sr_no,p_doc_name,p_doc_type);
}//Method insertDocMas() closing here
/*This class is for loading the data into the database==================================*/
public void loadSamples(int p_version, String p_doc_path,String p_project_name,int p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
int p_doc_detail_sr_no = -1;
//Date p_sysdate = new Date() ;
try{
Statement l_stmt = m_connection.createStatement();
ResultSet l_seq_doc_details = l_stmt.executeQuery("SELECT SEQ_DOC_DETAIL.NEXTVAL FROM DUAL");
if (l_seq_doc_details.next())
p_doc_detail_sr_no = l_seq_doc_details.getInt(1);
System.out.println("The Control AA");
System.out.println("The value of p_doc_detail_sr_no" + p_doc_detail_sr_no);
l_seq_doc_details.close();
l_stmt.close();
Thread.sleep(4000);
}catch(Exception e){
System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
try {System.out.println("The Control 6");
java.sql.Date current_date = new java.sql.Date(System.currentTimeMillis());
System.out.println("Creating row for actual-doc in DOC_DETAILS.. ");
//PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_DETAIL(DOC_DETAIL_SR_NO,DOC_MAS_SR_NO,DATE_OF_INSERT,ACTUAL_DOC)values(?,?,'"+current_date+"', empty_blob() )");
PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_DETAIL(DOC_DETAIL_SR_NO,DOC_MAS_SR_NO,DATE_OF_INSERT)values(?,?,?)");
l_pstmt.setInt(1,p_doc_detail_sr_no);
l_pstmt.setInt(2,p_doc_mas_sr_no);
l_pstmt.setDate(3,current_date);
System.out.println("The Control 6AA");
l_pstmt.execute(); // Execute SQL statement
l_pstmt.close(); // Close statement
System.out.println("Created.\nLoading <map.gif> into BLOB column for doc_detail...");
System.out.println("The Control 7");
// Retrieve the row just inserted, and lock it for insertion of the
}catch(Exception e){
System.out.println("Exception has occured at the time of inserting blob locators"+e);
try {
System.out.println("The Control 8");
l_dirPath = p_doc_path ;
PreparedStatement l_pstmt = m_connection.prepareStatement(
"CREATE OR REPLACE DIRECTORY BFILEDIR AS '" + l_dirPath + "' ");
l_pstmt.execute();
l_pstmt.close();
// Execute the prepared SQL Statement
} catch (Exception ex)
{ // Trap SQL errors
System.out.println("Error loading sample files ");
System.out.println("\n"+ex.toString());
System.out.println("The Control 8AA");
try{
// Insert the Image as a BFILE Column
// String abc = new String("INSERT INTO DOC_DETAIL(ACTUAL_DOC)VALUES(BFILENAME('BFILEDIR2','" + p_doc_name + "')) WHERE D0C_MAS_SR_NO = '" + p_doc_mas_sr_no + "';");
//System.out.println(abc);
//l_pstmt.executeQuery("insert into DOC_DETAIL(ACTUAL_DOC)values(BFILENAME('BFILEDIR','" + p_doc_name + "')) where D0C_MAS_SR_NO = '" + p_doc_mas_sr_no + "';");
String abc = new String("update DOC_DETAIL SET ACTUAL_DOC = BFILENAME('BFILEDIR','" + p_doc_name + "') where D0C_MAS_SR_NO = '"+p_doc_mas_sr_no+"' ");
System.out.println(abc);
PreparedStatement l_pstmt = m_connection.prepareStatement("update DOC_DETAIL SET ACTUAL_DOC = BFILENAME('BFILEDIR','" + p_doc_name + "') where DOC_MAS_SR_NO = '"+p_doc_mas_sr_no+"' ");
l_pstmt.executeQuery();
l_pstmt.close(); // Close the prepared Statement
drawBLOB(p_version,p_doc_mas_sr_no,p_project_name,p_doc_name, p_doc_type);
System.out.println("The Control 9");
} catch (Exception ex)
{ // Trap SQL errors
System.out.println("Error loading sample files ");
System.out.println("\n"+ex.toString());
}//Method closes here
* Retrieve the BLOB data from input BLOB column into a local file,
* and draws the image. The file type needs to be added here
public void drawBLOB(int p_version,int p_doc_mas_sr_no,String p_project_name, String p_doc_name,String p_doc_type) {
//String fileType this should be passed at some point to ensure that th e file gets the right extension
try { System.out.println("The Control 10");
Statement l_stmt = m_connection.createStatement();
// Execute the Query and get BFILE Locator as a result set
ResultSet l_rset = l_stmt.executeQuery("Select ACTUAL_DOC from DOC_DETAIL WHERE DOC_MAS_SR_NO= '"+p_doc_mas_sr_no+"' ");
//Note : Using Oracle Extension oracle.sql.BFILE to get BFILE Locator
oracle.sql.BFILE l_bfile = null;
// Loop through the Result Set
while(l_rset.next()) {
l_bfile = ((OracleResultSet)l_rset).getBFILE(1); // Get the BFILE Locator
System.out.println("Retrieved BFILE Locator..");
System.out.println("l_bfile :"+l_bfile);
l_rset.close(); // Close the ResultSet
l_stmt.close(); // Close the Statement
// Open the file with openFile Method of oracle.sql.BFILE class
l_bfile.openFile();
// Open the Input Binary Stream with getBinaryStream method of
// oracle.sql.BFILE class
InputStream f = l_bfile.getBinaryStream();
System.out.println("Opened Binary Stream ...");
size =f.available();
System.out.println("Actual Size:"+size+"Bytes");
int n = size;
int x=0;
System.out.println("First"+n+"bytes of the file one can read at a time");
b = new byte[size];
System.out.println("printing bytes"+b);
char ch=' ';
while(x<size)
ch=(char)f.read();
b[x]=(byte)ch;
//str+=ch;
x++;
System.out.println("The Control 11");
// file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_doc_name;
directoryMap( p_version, p_project_name, p_doc_name);//This method is called here
OutputStream fout = new FileOutputStream(file_path);
for(int i=0;i<b.length;i +=2)
//out.println(b);
fout.write(b[i]);
System.out.println("The Control 12");
drawMap(file_path,p_doc_name,p_doc_type);
} catch (Exception ex) { // Trap SQL and IO errors
System.out.println("Error in retrieving and drawing map for selected airport");
System.out.println("\n"+ex.toString());
* Create a label from the image filepassed, add the label to the image area
This part will have to be modified majorly
public void drawMap(String file_path, String p_doc_name,String p_doc_type)
//Refer to SIRExtOpen.java
System.out.println("The Control 13");
Runtime r = Runtime.getRuntime();
Process p = null;
if (p_doc_type.equals("html")&#0124; &#0124;p_doc_type.equals("htm"))
try{
p = r.exec( "C:\\Program Files\\Internet Explorer\\Iexplore.EXE " +file_path);
//repaint();
p.waitFor();
catch(Exception ex)
ex.printStackTrace();
System.out.println(ex);
System.out.println(ex.getMessage());
if(p_doc_type.equals("txt")&#0124; &#0124; p_doc_type.equals("sql")&#0124; &#0124; p_doc_type.equals("java"))
try
p = r.exec( "C:\\WINDOWS\\notepad.EXE " + p_doc_name); p.waitFor();
catch(Exception ex)
ex.printStackTrace();
System.out.println(ex);
System.out.println(ex.getMessage());
} // end of txt , sql , java if
if(p_doc_type.equals("xls"))
try
p = r.exec( "C:\\Program Files\\Microsoft Office\\Office\\excel.EXE " +file_path);
p.waitFor();
catch(Exception ex)
ex.printStackTrace();
System.out.println(ex);
System.out.println(ex.getMessage());
} // end of xls if
if(p_doc_type.equals("fmb"))
try
p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + file_path);p.waitFor();
catch(Exception ex)
ex.printStackTrace();
System.out.println(ex);
System.out.println(ex.getMessage());
} // end of fmb if
if(p_doc_type.equals("doc"))
try
p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + file_path);p.waitFor();
catch(Exception ex)
ex.printStackTrace();
System.out.println(ex);
System.out.println(ex.getMessage());
} // end of doc if
if(p_doc_type.equals("mpp"))
try
p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + file_path);p.waitFor();
catch(Exception ex)
ex.printStackTrace();
System.out.println(ex);
System.out.println(ex.getMessage());
} // end of mpp if
//Here you can write a statement for deleting the file in the root directory once the file is opened using any editor
}//end of method
* This method is called when a row is selected from the combo.
* It checks if there exists data in DOC_DETAIL for the selected
* file. If there exists data, it calls drawBLOB and writeCLOB to
* display the data
/*public void fileSelected(String p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
try {
System.out.println("Retrieving LOB details for selected file..");
// Create a SQL statement
Statement l_stmt = m_connection.createStatement();
// Query DOC_DETAILS for the selected file
java.sql.ResultSet l_lobDetails = l_stmt.executeQuery(
"SELECT ACTUAL_DOC FROM DOC_DETAILS "+
"WHERE DOC_MAS_SR_NO='"+p_doc_mas_sr_no+"'");
// Check if LOB columns exist
if (l_lobDetails.next()) {
// LOB details exist
// Display airport map and suggestion book (LOB details)
drawBLOB(l_lobDetails.getBlob(1),p_doc_name,p_doc_type);
//lobs.drawBLOB(((OracleResultSet)l_lobDetails).getBLOB(1),p_doc_name,p_doc_type);
//Should this be like this
System.out.println("Done retrieving and displaying LOB details");
} else {
// No LOB details
// m_GUI.m_loadButton.setEnabled(true);
//TO BE CHECKED OUT LATER m_loadButton This is a button in the form
System.out.println("No airport map and suggestion book exist for selected airport");
System.out.println("\nPress <Load Sample3 Files> to load LOB details");
l_lobDetails.close();
l_stmt.close();
} catch (Exception ex) { // Trap SQL errors
System.out.println("Error retrieving LOB Details for the selected airport");
System.out.println(ex.toString());
public void directoryMap(int p_version,String p_project_name,String p_doc_name) {//start of the method
System.out.println("The Control 14");
if (p_version==1)
File f = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
if(f.exists())
file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
else
File f1 = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
}//end of inner else
}//end of else
else if(p_version==2)
File f = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
if(f.exists())
file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
else
File f1 = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
}//end of inner else
}//end of else
else if(p_version==3)
File f = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
if(f.exists())
file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
else{
File f1 = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
}//end of inner else
}//end of outer else
else
System.out.println("System has gone into 4th version");
}//end of method
}//end of class
null

Hi
Have you found a workaround for this problem? im having a similiar problem and am interested in its solution.....

Similar Messages

  • Download from BFILE problem

    Hello,
    I have the following problem:
    1. I can upload PDF files into BFILE(s) - in the DATA_PUMP_DIR (dba_directories table)
    2. The uploaded file can be opened/viewed with Adobe Acrobat Reader.
    3. I use a stored procedure do download the PDF files from my browser.
    4. the download works ok but the file can no longer be opened/viewed using Adobe Acrobat Reader.
    5. I did a hex compare of 2 pdf files (the uploaded file and the downloaded file) and I think it is a CR vs CRLF conversion problem.
    I am using Oracle 10g XE on a Linux box and Windows as a client. The upload/download is part of a APEX application.
    This is the code used to download the BFILE:
    Note: v_mime is set to 'application/pdf'.
            x_bfile := BFILENAME ('DATA_PUMP_DIR', p_file);
            DBMS_LOB.fileopen (x_bfile, DBMS_LOB.LOB_READONLY);
            -- set up HTTP header
            -- use an NVL around the mime type and
            -- if it is a null set it to application/octect
            -- application/octect may launch a download window from windows
            owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
            -- the filename will be used by the browser if the users does a save as
            htp.p('Content-Disposition:  attachment; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');
            -- close the headers
            owa_util.http_header_close;
            BEGIN
                LOOP
                    DBMS_LOB.READ (x_bfile,
                                   n_size,
                                   n_pos,
                                   x_buffer);
                    HTP.prn (UTL_RAW.cast_to_varchar2 (x_buffer));
                    -- increment number of bytes read
                    n_pos := n_pos + n_size;
                END LOOP;
            EXCEPTION
                WHEN NO_DATA_FOUND THEN
                    NULL;
            END;Any suggestions?
    Thanks,
    Catalin Florean.

    You could try using wpg_docload.download_file instead of htp.prn.
    Here is part of the procedure I use for downloading MP3 files from BFILES:
                    owa_util.http_header_close;
                    dbms_lob.createTemporary(TBlob, true);  
                    dbms_lob.open(Lob_loc, dbms_lob.file_readonly);
                    dbms_lob.loadfromfile( TBlob, Lob_loc, dbms_lob.getlength(Lob_loc) );
                    dbms_lob.fileclose(Lob_loc);
                    -- download the BLOB           
                    wpg_docload.download_file( TBlob );    
                    dbms_lob.freeTemporary( TBlob );You would replace my Lob_loc variable with your x_bfile.

  • BLOB, BFILE problems

    We have tried different methods to get these data types to work in a PO8 environment. If we use the Oracle Navigator we can store and read blob data. When we try the same using JDBC 2.0 driver we can not get even the insert to work correctly. Has anyone ever been successful in getting it work. The samples of codes in many books don't seem to have been tested either because they don't work either!
    For example, using the BFILE option (example given by Steve Bobowski)gave us a FILEOPEN exception ORA error 22285 (No directory exists or cannot open file). The directory and the file does exist and the user has the required permissions!
    Any help?

    Chapter 7 in the Oracle Call Interface Programmer's Guide discusses [LOB and BFILE operations|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci07lob.htm#g452677]. Given that you are posting here, I assume you are interested in using the OCI interface and that you are familiar with the basics of OCI programming. If not, you'll want to read the other chapters in the OCI Programmer's Guide.
    Justin

  • Problem with BFILE closure

    I have a problem with a pending session (Oracle 8.1.7, Windows 2000). The active process is waiting for a BFILE to close (BFILE closure). It has been waiting > 7000 secs. The file to read is a simple csv-file with 10 lines.
    I'm using the widely spread "ftp"-package (I have removed all procedures with a "binary" part as 8i dont have the "put_raw" feature. I've used binary part of the package in 10g without any problems).
    The procedure where the problem occurs:
    FUNCTION get_local_ascii_data (p_dir IN VARCHAR2,
    p_file IN VARCHAR2)
    RETURN CLOB IS
    l_bfile BFILE;
    l_data CLOB;
    l_amount BINARY_INTEGER := 32767;
    l_pos INTEGER := 1;
    wText varchar2(32767);
    BEGIN
    DBMS_LOB.createtemporary (lob_loc => l_data,
    cache => TRUE,
    dur => DBMS_LOB.call);
    l_bfile := BFILENAME(p_dir, p_file);
    DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
    DBMS_LOB.loadfromfile(l_data, l_bfile, DBMS_LOB.getlength(l_bfile));
    DBMS_LOB.fileclose(l_bfile);
    RETURN l_data;
    END;
    The file to be read contains the following:
    1;john;heinrich;vejnavn 1;2650;hvidovre
    2;john;heinrich;vejnavn 2;2650;hvidovre
    3:john;heinrich;vejnavn 3;2650;hvidovre
    4;john;heinrich;vejnavn 4;2650;hvidovre
    5;john;heinrich;vejnavn 5;2650;hvidovre
    6;john;heinrich;vejnavn 6;2650;hvidovre
    7;john;heinrich;vejnavn 7;2650;hvidovre
    8;john;heinrich;vejnavn 8;2650;hvidovre
    9;john;heinrich;vejnavn 9;2650;hvidovre
    10;john;heinrich;vejnavn 10;2650;hvidovre
    Any clue?
    It locks the package in question, and killing the session dont free the package. Only a db shotdown will free the package. Is there a way to "close" the bfile?

    What information is there in your post indicating the BFILE did not close and that this is the cause of the problem?
    8.1.7 is so old I haven't seen it in almost a decade so I can't test this out but it seems to me you should be focusing new development efforts on a version of the product that has been supported during the current millennium.

  • Problems with bfile

    I have a plsql block which reads from bfile into a varchar2 .
    the problem is the entire content of the bfile is read in hexadecimal format.
    i get the hexadecimal values int the varchar2.
    how do i get it in proper character format

    Hi Csound1
    approx every 30 seconds the browser freezes and 'saving' appears in the top bar of icloud mail. The cursor starts spinning and then after about 8 secs I can start typing again. I also fiund that about 5-6 times a day my icloud browser tab showing mail just close and return to the main icloud menu page showing icons for mail, calender, notes etc

  • CF11: problem with BFILE documents retrival

    Hi all,
    We have encountered this problem after upgrading to CF11.  We used to use cfquery to select a bfile column directly like below:
    <cfquery name="getDoc">
    select bfile_column
    from a_table
    where id = #id#
    </cfquery>
    we then use cfcontent to open the file directly:
    <cfset docstream = getDoc.bfile_colum />
    <cfcontent type="application/pdf" variable = "#docstream#" />
    This worked fine for us on CF9.  However after we upgrade to CF11, the query stops working.  The query simply hangs there, returning no result.  We found it out by removing all the code but simply leaving the query on a test page and the test page never opened until it timed out. 
    The data source we use is for oracle.  We have checked "BLOB" and "CLOB" boxes for the data source to make sure large content can be retrieved.
    Has anybody run into this same problem?  If so, have you resolved it?
    Your help is greatly appreciated!

    Or
    'C:\Programme\Text_ordner'
    :)

  • Problems while reading and displaying .pdf-Documents from Bfile

    Hi
    I want to read and display .pdf-Documents in Adobe-Reader that are stored as BFile. While displaying the Document Adobe Reader is showing several Errors like " ..less Picture-Data read than expected.. ". Is this a Buffer-Problem? or whatelse ??
    Thanks for help
    null

    PrintStream wr = new PrintStream(socket.getOutputStream());
    wr.close();I suspect this is the problem. You could try socket.shutdownOutput() - or you could just leave the streams alone and let socket.close() shut things down.
    Grant

  • Bfile image problem

    Hi all,
    I am using Oracle 10.2.0.2.0 on x86_64 GNU/Linux .
    I am using a table with column bfile datatype. Bfile column links to oracle directory "frameroot" which contains image frames. when i check data of link (bfile) it shows the below :
    Name : 2009_pre
    Data Length : 55044
    File Exists : true
    Directory aliase : FRAMEROOT
    but when i click image option its is giving the below error :
    "*Image could not be decoded from the binary stream*".
    As i think sql developer should show the image of the bfile datatype.
    Please suggest.
    Thanks
    Vipin

    The Oracle database does not have a "click image option."
    What product do you have? In what version?
    If it is an Oracle product post your question in the correct forum.
    If it is not an Oracle product post your question on the correct website.
    Please note also that a BFILE has no way of knowing whether the physical file still exists.

  • Bfile image problem---please ignore this thread

    Hi all,
    I am using Oracle 10.2.0.2.0 on x86_64 GNU/Linux .
    I am using a table with column bfile datatype. Bfile column links to oracle directory "frameroot" which contains image frames. when i check data of link (bfile) in oracle sql developer it shows the below :
    Name : 2009_pre
    Data Length : 55044
    File Exists : true
    Directory aliase : FRAMEROOT
    but when i click image option its is giving the below error :
    "Image could not be decoded from the binary stream".
    As i think sql developer should show the image of the bfile datatype.
    I am using oracle sql developer version 1.2.1
    Please suggest.
    Thanks
    Vipin
    Edited by: VipinK on Jun 8, 2010 10:07 PM

    Duplicate post. Please change the subject to "Please Ignore"
    Please never do this.
    thank you.
    PS: There is a SQL*Developer forum and that is the only place to post questions about SQL*Developer.

  • Problem in bfile

    hi ,
    i made a table emp_dat whose structure is,
    empno number primary key,
    picture blob,
    bio clob,
    hr_file bfile
    then i inserted a word file in hr_file column. after that when i tried to display its contents through select statement it gave an error which reads like this,
    procedure,function,packageor type not allowed. plz help me in finding the solution.
    thanking u
    akhilesh

    The procedure to select data - open the file, read and store the data into a variable and then display. To achieve you need to use FILEOPEN & READ procedures of DBMS_LOB package. To display the data use PUT_LINE procedure of DBMS_OUTPUT package.
    To open the file using FILEOPEN you need two parameters
    1. File Locator
    2. Open Mode (ex: 'READ', 'WRITE' )
    To read the data you need to use the READ procedure of DBMS_LOB package which takes four parameters
    1. The File Locator
    2. The number of bytes or characters to be read
    3. The offset (starting point of the read) from the beginning of the BFILE value
    4. The output data from the READ procedure (i.e., variable to hold the output)
    Regards,
    Murali Mohan

  • Problems with moving files to ora directory UTL_FILE.PUT_RAW - ORA-29285

    hi,
    i'm using apex 4.1
    i have a procedure which moves my file from apex_application_files to ORA directory.
    if i choose a text file or small word document which is 1kb, it works. but if i have pdf file (85kb) or word document (16kb) it gives me ORA-29285: file write error
    what's my problem?
    PROCEDURE put_file_to_server (p_filename IN VARCHAR2,p_cert_type IN VARCHAR2,p_cert_pk IN NUMBER)
    AS
    l_file UTL_FILE.file_type;
    l_blob_len INTEGER;
    l_pos INTEGER := 1;
    l_amount BINARY_INTEGER := 32767;
    l_buffer RAW (32767);
    v_new_filename VARCHAR2(100);
    v_bfile BFILE ;
    BEGIN
    -- delete from apex_application_files;
    --Neuen Dateinamen generieren
    v_new_filename := p_cert_type||'_'||p_cert_pk;
    v_bfile := BFILENAME (v_directory, v_new_filename);
    --Datei erstellen
    l_file := UTL_FILE.fopen(v_directory,v_new_filename,'w');
    IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
    FOR rec IN (select blob_content lblob from apex_application_files where rownum = 1)
    LOOP
    l_blob_len := DBMS_LOB.getlength(rec.lblob);
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '||l_blob_len);
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.read (rec.lblob, l_amount, l_pos, l_buffer);
    UTL_FILE.put_raw (l_file, l_buffer, FALSE);
    l_pos := l_pos + l_amount;
    END LOOP;
    COMMIT;
    END LOOP;
    --Datei schließen
    UTL_FILE.fclose(l_file);
    else
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesn't exist');
    end if;
    EXCEPTION
    WHEN OTHERS
    THEN
    -- Close the file if something goes wrong.
    IF UTL_FILE.is_open (l_file) THEN
    UTL_FILE.fclose (l_file);
    END IF;
    delete from apex_application_files;
    RAISE;
    delete from apex_application_files;
    END put_file_to_server;

    Sorry but din't test this...Can you give it a try and see if this works?
    PROCEDURE put_file_to_server(
        p_filename  IN VARCHAR2,
        p_cert_type IN VARCHAR2,
        p_cert_pk   IN NUMBER)
    AS
      l_file UTL_FILE.file_type;
      l_blob_len INTEGER;
      l_pos      INTEGER      := 1;
      l_amount BINARY_INTEGER := 32767;
      l_buffer RAW (32767);
      v_new_filename VARCHAR2(100);
      v_bfile BFILE ;
      vblob BLOB;
      vstart NUMBER := 1;
      my_vr RAW(32000);
      bytelen NUMBER := 32000;
      LEN     NUMBER;
    BEGIN
      -- delete from apex_application_files;
      --Neuen Dateinamen generieren
      v_new_filename := p_cert_type||'_'||p_cert_pk;
      v_bfile        := BFILENAME (v_directory, v_new_filename);
      --Datei erstellen
      --l_file                          := UTL_FILE.fopen(v_directory,v_new_filename,'w');
      l_file                          := UTL_FILE.fopen(v_directory,v_new_filename, 'WB', 32760);
      IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
        cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
        FOR rec IN
        (SELECT blob_content lblob,
          LENGTH(blob_content) LEN
        FROM apex_application_files
        WHERE rownum = 1
        LOOP
          cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '|| LEN);
          IF LEN < 32760 THEN
            utl_file.put_raw(l_file,lblob);
            utl_file.fflush(l_file);
          ELSE -- write in pieces
            vstart      := 1;
            WHILE vstart < LEN
            LOOP
              dbms_lob.read(vblob,bytelen,vstart,my_vr);
              utl_file.put_raw(l_file,my_vr);
              utl_file.fflush(l_file);
              -- set the start position for the next cut
              vstart := vstart + bytelen;
              -- set the end position if less than 32000 bytes
              x         := x - bytelen;
              IF x       < 32000 THEN
                bytelen := x;
              END IF;
            END LOOP;
          END IF;
         END LOOP;
        ELSE
          cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesnt exist');
        END IF;
        utl_file.fclose(l_file);
      EXCEPTION
      WHEN OTHERS THEN
        -- Close the file if something goes wrong.
        IF UTL_FILE.is_open (l_file) THEN
          UTL_FILE.fclose (l_file);
        END IF;
        DELETE FROM apex_application_files;
        RAISE;
        DELETE FROM apex_application_files;
      END put_file_to_server;Edited by: Vitor Rodrigues on 17/Fev/2012 12:03

  • Problem in XML Parsing via oracle procedure...

    Hi,
    I wrote one oracle procedure for xml parsing.
    I have one valid xml file which has "encode UTF-8". The XML file contains some comments also. While we are parsing the xml file at that time it is not parse successfully and also it is not giving any error. After the following line it is skip rest of the codes(lines).
    dbms_xmlparser.parseclob(l_parser, l_clob);
    At the end of the xml file there are some comments which is like "<!-- abc --> ".
    When I am changing the "encode UTF-8 to ISO-88596-1" & removing the comments which wrote on bottom of the file then its working fine, but the files which we are getting from the system is contains the encode UTF-8 and we don't want to preprocess on that xml files. Even if we will do that via shell script or perl script then it will be overhead to the system and in a single stroke our system will parse more than 5k xml files, so if we will do some preprocess on it, it will take some more time approx 1-2 minutes extra.
    So, If someone knows any solution of this problem, then please guide & help me on this.
    My xml file structure is as follows:-
    <?xml version="1.0" encoding="UTF-8"?>
    <mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
         <child>
              <child1>32.401 V5.5</child1>
              <child2>ZoneGate</child2>
         </child>
         <mc>
              <newid>
                   <id>12</id>
              </newid>
              <mindex>
                   <date>20111102180000</date>
                   <mt>abc1</mt>
                   <mt>abc2</mt>
                   <mvalue>
                        <r>val_1</r>
                        <r>val_2</r>
                   </mvalue>
              </mindex>
         </mc>
    </mcd>
    <!--
    ALARM STATUS
    morning 10
    afternoon 14
    evening 18
    night 22
    -->
    <!--
    PARAM:EID = 1
    PARAM:GId = 3
    PARAM:GSId = 0
    --!>
    And my oracle procedure is as follows:-
    create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
    -- Defining the variables
    ecode               NUMBER;
    emesg           VARCHAR2(200);
    l_bfile      BFILE;
    l_clob      CLOB;
    l_dest_offset      INTEGER:=1;
    l_src_offset      INTEGER:=1;
    l_Char_set_id      NUMBER := NLS_CHARSET_ID('UTF8');
    l_lang_context      INTEGER := dbms_lob.default_lang_ctx;
    l_warning           INTEGER;
    l_parser dbms_xmlparser.Parser;
    l_doc dbms_xmldom.DOMDocument;
    l_nl1 dbms_xmldom.DOMNodeList;
    l_nl2 dbms_xmldom.DOMNodeList;
    l_n dbms_xmldom.DOMNode;
    node1 dbms_xmldom.DOMNode;
    colid integer ; -- column id used for identifying which column it belongs.
    l_xmltype XMLTYPE;
    sub_xmltype XMLTYPE;
    num_nodes number;
    l_index PLS_INTEGER;
    l_subIndex           PLS_INTEGER;
    starttime Date;
         temp_datatime VARCHAR(25);
    columnname varchar2(300);
    columnvalue varchar2(300);
    -- creating a Type which is a type of "test_hem" table RowType, which I created in SVN server
    TYPE tab_type IS TABLE OF test_hem%ROWTYPE;
    t_tab tab_type := tab_type();
    BEGIN
    -- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
    l_bfile := BFileName('MY_FILES', xmlfile);
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    --dbms_lob.loadFromFile(dest_lob => l_clob,
    -- src_lob => l_bfile,
    -- amount => dbms_lob.getLength(l_bfile));
    dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
    l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
    dbms_lob.close(l_bfile);
    -- make sure implicit date conversions are performed correctly
    dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
    dbms_output.put_line('Date format set');
    -- Create a parser.
    l_parser := dbms_xmlparser.newParser;
    dbms_output.put_line('output 1');
    -- Parse the document and create a new DOM document.
    dbms_xmlparser.parseclob(l_parser, l_clob);
    dbms_output.put_line(' passed parsing');
    l_doc := dbms_xmlparser.getDocument(l_parser);
    dbms_output.put_line(' passed getdocument');
    -- Free resources associated with the CLOB and Parser now they are no longer needed.
    dbms_lob.freetemporary(l_clob);
    dbms_xmlparser.freeParser(l_parser);
    -- Get a list of all the EMP nodes in the document using the XPATH syntax.
    l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
    -- Loop through the list and create a new record in a tble collection
    FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
    l_n := dbms_xmldom.item(l_nl1, cur_sel);
    t_tab.extend;
    -- Use XPATH syntax to assign values to he elements of the collection.
    dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
    -- putting the state and vendorname into the table rowtype
    dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
    END LOOP;
    -- getting the version and putting into the table rowtype
    l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
    dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
    -- selecting the nodes whose starting tag is "mindex"
    l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
    -- checking the total number of nodes whose starting through "mi"
    num_nodes := dbms_xmldom.getLength(l_nl1);
    l_index := 1;
    -- For loop to iterate the nodes.
    FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
    -- whole current node is selected and storing into the node1 variable
    node1 := dbms_xmldom.item(l_nl1, cur_sel);
    -- setting the xmltype as AL32UTF8
    l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
    -- if selecting parent node containing the mt child node then only proceed else skip that parent node.
    IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
    -- fetch the datatime, convert it into to_date format and store it into table rowtype
    temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
    t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
    l_subIndex := 1;
                                  while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
                                  -- getting mt and corresponging mvalue/r values
    dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
    dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
    l_subIndex := l_subIndex + 1;
    -- getting the column to which this mapping belongs.
    select columnid into colid from abc_table where columnname=name;
    CASE colid
    WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
                             WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
                             WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
    ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
    END CASE; -- end of case statement.
    END LOOP;
    -- Insert data into the real table from the table collection.
    FORALL i IN t_tab.first .. t_tab.last
    INSERT INTO test_hem VALUES t_tab(i);
    END IF;
    l_index := l_index + 1;
    COMMIT;
    END LOOP;
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    ecode := SQLCODE;
    emesg := SQLERRM;
    dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
         dbms_lob.freetemporary(l_clob);
         dbms_xmlparser.freeParser(l_parser);
         dbms_xmldom.freeDocument(l_doc);
    END;

    Sorry Odie,
    I am new to this site as well as PL/SQL. I am giving additional details which you had mentioned in your last comments.
    our Oracle Database version is "10.2.0.4.0"
    The structure of target table Instrument_Details is as follows:
    Create table Instrument_Details (
    instrument_id          Integer  Primary Key,
    provider_name          Varchar2(32),
    version_number          Varchar2(32),
    location_id                  Integer,
    installation_date             Date,
    granularity                  Integer,
    time_out                  Integer );
    Note:- Here test_hem is alias of Instrument_details.
    Here instrument_id is a primary key.
    provider_name contains the child2 xml tag value.
    version_number contains the child1 xml tag value.
    location_id contains the newid/id value which is map to other table which fetching the location name corresponding to the location_id.
    installation_date contains the date xml tag value.
    Now we have created one mapping tables where we mapped the xml tag values "mt" with table column name means "abc1 = granularity", "abc2 = time_out" in that table.
    these table column value are written under mvalue xml tag.
    _Our Database Character set is_:-
    NLS_CHARACTERSET WE8ISO8859P1
    Now as you suggest me to format your code. I am writing the xml code and procedure code again.
    My xml file structure is as follows:-
    <?xml version="1.0" encoding="UTF-8"?>
    <mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
      <child>
          <child1>32.401 V5.5</child1>
          <child2>ZoneGate</child2>
      </child>
      <mc>
          <newid>
               <id>12</id>
          </newid>
      <mindex>
           <date>20111102180000</date>
           <mt>abc1</mt>
           <mt>abc2</mt>
           <mvalue>
                 <r>val_1</r>   -- here val_1 and val_2 are numeric values
                 <r>val_2</r>
            </mvalue>
      </mindex>
      </mc>
    </mcd>
    <!--
    ALARM STATUS
    morning 10
    afternoon 14
    evening 18
    night 22
    -->
    <!--
    PARAM:EID = 1
    PARAM:GId = 3
    PARAM:GSId = 0
    --!> And my oracle procedure is as follows:-
    create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
    -- Defining the variables
    ecode NUMBER;
    emesg VARCHAR2(200);
    l_bfile BFILE;
    l_clob CLOB;
    l_dest_offset INTEGER:=1;
    l_src_offset INTEGER:=1;
    l_Char_set_id NUMBER := NLS_CHARSET_ID('UTF8');
    l_lang_context INTEGER := dbms_lob.default_lang_ctx;
    l_warning INTEGER;
    l_parser dbms_xmlparser.Parser;
    l_doc dbms_xmldom.DOMDocument;
    l_nl1 dbms_xmldom.DOMNodeList;
    l_nl2 dbms_xmldom.DOMNodeList;
    l_n dbms_xmldom.DOMNode;
    node1 dbms_xmldom.DOMNode;
    colid integer ; -- column id used for identifying which column it belongs.
    l_xmltype XMLTYPE;
    sub_xmltype XMLTYPE;
    num_nodes number;
    l_index PLS_INTEGER;
    l_subIndex PLS_INTEGER;
    starttime Date;
    temp_datatime VARCHAR(25);
    columnname varchar2(300);
    columnvalue varchar2(300);
    -- creating a Type which is a type of "Instrument_Details" table RowType, which I created in SVN server
    TYPE tab_type IS TABLE OF Instrument_Details%ROWTYPE;
    t_tab tab_type := tab_type();
    BEGIN
    -- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
    l_bfile := BFileName('MY_FILES', xmlfile);
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    --dbms_lob.loadFromFile(dest_lob => l_clob,
    -- src_lob => l_bfile,
    -- amount => dbms_lob.getLength(l_bfile));
    dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
    l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
    dbms_lob.close(l_bfile);
    -- make sure implicit date conversions are performed correctly
    dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
    dbms_output.put_line('Date format set');
    -- Create a parser.
    l_parser := dbms_xmlparser.newParser;
    dbms_output.put_line('output 1');
    -- Parse the document and create a new DOM document.
    dbms_xmlparser.parseclob(l_parser, l_clob);
    *-- Below lines are skipping....*
    dbms_output.put_line(' passed parsing');
    l_doc := dbms_xmlparser.getDocument(l_parser);
    dbms_output.put_line(' passed getdocument');
    -- Free resources associated with the CLOB and Parser now they are no longer needed.
    dbms_lob.freetemporary(l_clob);
    dbms_xmlparser.freeParser(l_parser);
    -- Get a list of all the EMP nodes in the document using the XPATH syntax.
    l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
    -- Loop through the list and create a new record in a tble collection
    FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
    l_n := dbms_xmldom.item(l_nl1, cur_sel);
    t_tab.extend;
    -- Use XPATH syntax to assign values to he elements of the collection.
    dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
    -- putting the state and vendorname into the table rowtype
       dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
    END LOOP;
    -- getting the version and putting into the table rowtype
       l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
      dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
    -- selecting the nodes whose starting tag is "mindex"
      l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
    -- checking the total number of nodes whose starting through "mi"
      num_nodes := dbms_xmldom.getLength(l_nl1);
    l_index := 1;
      -- For loop to iterate the nodes.
      FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
      -- whole current node is selected and storing into the node1 variable
      node1 := dbms_xmldom.item(l_nl1, cur_sel);
      -- setting the xmltype as AL32UTF8
       l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
      -- if selecting parent node containing the mt child node then only proceed else skip that parent node.
        IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
      -- fetch the datatime, convert it into to_date format and store it into table rowtype
        temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
        t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
        l_subIndex := 1;
       while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
    -- getting mt and corresponging mvalue/r values
       dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
      dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
      l_subIndex := l_subIndex + 1;
      -- getting the column to which this mapping belongs.
      select columnid into colid from abc_table where columnname=name;
      CASE colid
      WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
      WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
      WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
          ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
      END CASE; -- end of case statement.
      END LOOP;
    -- Insert data into the real table from the table collection.
      FORALL i IN t_tab.first .. t_tab.last
        INSERT INTO test_hem VALUES t_tab(i);
      END IF;
      l_index := l_index + 1;
    COMMIT;
    END LOOP;
    commit;
    EXCEPTION
      WHEN OTHERS THEN
      ecode := SQLCODE;
      emesg := SQLERRM;
      dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
      dbms_lob.freetemporary(l_clob);
      dbms_xmlparser.freeParser(l_parser);
      dbms_xmldom.freeDocument(l_doc);
    END;Thanks in advance for your help...

  • Problem with loading XML file from directory.

    Hello everyone.
    *1)* I have directory defined by DBA. I have read, write privileges. I can read file from this directory using UTL_FILE, I can create file in this directory using UTL_FILE. I tried many times and it does not seem to be any problems.
    *2)* I have very simple XML table (with just one column of xmltype). I can insert into this column using:
    insert into temp_xml values (
    Xmltype ('<something></something>')
    *3)* When executing
    insert into temp_xml values (
    Xmltype (
    bfilename('XML_LOCATION', 'sample.xml'),
    nls_charset_id('AL16UTF8')
    I'm receiving an error:
    Error report:
    SQL Error: ORA-22288: file or LOB operation FILEOPEN failed
    ORA-06512: at "SYS.DBMS_LOB", line 523
    ORA-06512: at "SYS.XMLTYPE", line 287
    ORA-06512: at line 1
    22288. 00000 - "file or LOB operation %s failed\n%s"
    *Cause:    The operation attempted on the file or LOB failed.
    *Action:   See the next error message in the error stack for more detailed
    information. Also, verify that the file or LOB exists and that
    the necessary privileges are set for the specified operation. If
    the error still persists, report the error to the DBA.
    *4)* Previously I was receiving more descriptive errors like permission denied, file not exists etc. This time there is no clear description apart from "file or LOB operation %s failed\n%s". I'm sure I can access this file in this directory (I used UTL_FILE to dbms_output the content).
    Any help would be greatly appreciated.
    Regards
    Marcin Jankowski

    Hi Marcin,
    Welcome to the forums.
    One very important thing with Oracle XML : please always give your database version, all four digits (e.g. 10.2.0.4).
    Does the directory resides on the same machine as the database? Which OS?
    Does any of the following work ?
    DECLARE
       v_lob   CLOB;
       v_file  BFILE;
    BEGIN
       v_file := BFILENAME('XML_LOCATION','sample.xml');
       DBMS_LOB.createtemporary(v_lob, true);
       DBMS_LOB.fileopen(v_file);
       DBMS_LOB.loadfromfile(v_lob, v_file, DBMS_LOB.getlength(v_file));
       INSERT INTO temp_xml VALUES( xmltype(v_lob) );
       DBMS_LOB.fileclose(v_file);
       DBMS_LOB.freetemporary(v_lob);
    END;
    DECLARE
       v_lob   CLOB;
    BEGIN
       v_lob := DBMS_XSLPROCESSOR.read2clob('XML_LOCATION', 'sample.xml', nls_charset_id('AL16UTF8'));
       INSERT INTO temp_xml VALUES( xmltype(v_lob) );
    END;
    /

  • Facing problem in xml schema xsd file registration

    Hi,
    i am facing problem in xml schema xsd file registration when
    the number of column is more. It is showing persing error.
    if i am deleting few column from xsd file . It is working otherwise
    showing error. Is there any solution for that please suggest me.
    The Error is
    ORA-31011:XML parsing failed
    ORA_19202: Error occurred in XML processing
    LPX-00230 : (message vary time to time-like invalid tag ending etc.)
    Regards
    Manoranjan
    and thanks in advance

    Where is you XML coming from. Are you sure it's valid. If you are hard coding it as a SQL String constant are you hitting the 4k / 32K limit on the size of SQL / PL/SQL constant. Have you tried loading the content from a bfile..

  • Directory problem....(utl_file related)

    create directory test_sukanta_dir as 'C:/Oracle/Sukanta';+
    when this statement run successfully ..its mean it create a Directory named by Sukanta which is inside C drive , Oracle Directory..is it..if yes when this statement run successfully no such directory created..inside C drive named by Oracle..what is the problem...plzzz help me...
    i am create this directory from a user..it have the privilege to create directory..

    Create directory doesnot create the directory, its an alias to an already existing directory.
    The following is a snippet from oracle docs -
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_5007.htm
    Use the CREATE DIRECTORY statement to create a directory object. A directory object specifies an alias for a directory on the server file system where external binary file LOBs (BFILEs) and external table data are located. You can use directory names when referring to BFILEs in your PL/SQL code and OCI calls, rather than hard coding the operating system path name, for management flexibility.

Maybe you are looking for

  • How do i delete perticular type file(*.enc) from folder/File recursively ?

    i know File class and File[ ] of java but can u give me code to delete (*.enc) file from folder inside folder. i mean recursively. i used : if(encFile.isDirectory()) File []fileList = (new File(encF)).listFiles(); //File[] fileList2= (new File(encF))

  • Opening Balances for Project Costing in R12

    Hi All, What are the Open transactions should be migrated as Opening Balance in Project Costing (R12) for Projects and Tasks. Here at client place cost will come from Inv, PO, AP and OTL to Project costing (R12). Can you please explain in detail (Ope

  • [iPhone] Display text on a tool bar programmatically

    Hi, I'm adding a toolbar on the bottow of my view programmatically so I can update what button is available depending on the current context. And I would like to have a status text show in that toolbar (such as "loading...", "computing...", ... with

  • How can I make Outlook 2011 keep fonts as I set them?

    When I send an email from Outlook 2011, the fonts I have set don't seem to hold.  When a Windows user replies, I can see my original email has lost its formatting with the text showing in a variety of different fonts and sizes.  This makes for an unp

  • Where are files stored?

    In the midst of recovering from a hard drive failure, the one thing I can't figure out is where the documents for my iWeb site (backups on my iDisk: web.sites.iweb.site) should be placed on my hard drive in order to be accessed by iWeb when I launch