Run error in inserting blob

Hi good Eve everyone,

I'm trying to insert a blob in a table. I created a c:\images directory that contains all the images including Afghanistan.gif

I then created

my table

Looks like that

Name of Type Null

-------- ---- ------------

COUNTRY VARCHAR2 (30)

COUN_IMG BLOB

then the procedure to insert as below

create or replace

PROCEDURE insert_Blob (Country1 IN varchar2, p_filename IN VARCHAR2)

AS

l_blob BLOB;

l_bfile BFILE.

BEGIN

INSERT INTO ex_countryflag

VALUES (COUNTRY1, EMPTY_BLOB ())

return COUN_IMG IN l_blob;

l_bfile: = BFILENAME ('images', p_filename);

DBMS_LOB. FileOpen (l_bfile);

DBMS_LOB. LoadFromFile (l_blob, l_bfile,

DBMS_LOB. GetLength (l_bfile));

DBMS_LOB. FileClose (l_bfile);

commit;

END insert_blob;

When I'm compiling there is no error

DECLARE

COUNTRY1 VARCHAR2 (200);

P_FILENAME VARCHAR2 (200);

BEGIN

COUNTRY1: = 'AFGHANISTAN ';

P_FILENAME: = "Afghanistan.gif";

() INSERT_BLOB

Country1 = > countries1.

P_FILENAME = > P_FILENAME

);

END;

When I run it I get errors of

ORA-30687: session terminated by the debugger

ORA-22285: non-existent directory or file for FILEOPEN operation

Running PL/SQL: CALL the DBMS_DEBUG_JDWP. DISCONNECT()

No more data to read from socket

Process is complete.

Disconnection from the dataaudit database.

Debugger disconnected from the database.

but I'm sure that all the images are present in the images directory

thanking you in advance

Prakash

l_bfile: = BFILENAME ('images', p_filename);

Try 'IMAGES' (uppercase).

Tags: Database

Similar Questions

  • Error when inserting Blob by stored procedure

    Hi there and thank you for your time,.

    I am running a console application in .NET which resembles a particular file on my hard drive, runs through all files, captures the content via a FileStream, the type (by checking the registry), the name and a foreign key which he rises before insertion. This is my code:

    public void Insert (MyFileModel file) information gathered by the System.IO.FileInfo object //contains
    {
    Con OracleConnection = new OracleConnection (System.Configuration.ConfigurationManager.ConnectionStrings ["Oracle"]. ConnectionString);
    con. Open();
    OracleCommand cmd = new OracleCommand();
    cmd.CommandText = INSERT_FILE;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd. Connection = con;
    cmd. Parameters.Add (": p_in_file_contents", OracleDbType.Blob);
    cmd. Parameters.Add (": p_in_filename", OracleDbType.Varchar2);
    cmd. Parameters.Add (": p_in_item_num", OracleDbType.Int32);
    cmd. Parameters.Add (": p_in_file_content_type", OracleDbType.Varchar2);
    cmd parameters [0]. Value = file. FileContents; Byte [], populated from a file stream
    cmd parameters [1]. Value = file. File name; string
    cmd parameters [2]. Value = file. ItemNum; int?
    cmd parameters [3]. Value = file. FileContentType; string
    cmd ExecuteNonQuery());
    con. Close();
    con. Dispose();
    }

    INSERT_FILE (part of a set with the other working procedures) are:

    PROCEDURE INSERT_FILE (p_in_file_contents IN p_in_file_content_type IN varchar2, p_in_item_num in numbers, p_in_filename IN varchar2, blob)

    IS

    BEGIN

    INSERT INTO mytable
    (FILE_CONTENTS, FILENAME, CREATE_DATE, ITEM_NUM, IS_DELETED, FILE_CONTENT_TYPE)
    VALUES
    (p_in_file_contents, p_in_filename, SYSDATE, p_in_item_num, 0, p_in_file_content_type);

    END INSERT_FILE;

    Here's the code LOB on the table. I do not change no matter what this code, is any of the default:

    (STORE AS) LOB (FILE_CONTENTS)
    TABLESPACE RECENTES5
    ALLOW ONLINE STORAGE
    CHUNK 32768
    RETENTION
    NOCACHE
    NOLOGGING
    INDEX)
    TABLESPACE RECENTES5
    STORAGE)
    INITIAL OF 160K
    ACCORDING TO 1 M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    DEFAULT USER_TABLES
    ))
    STORAGE)
    INITIAL OF 160K
    ACCORDING TO 1 M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    DEFAULT USER_TABLES
    ))
    TABLESPACE RECENTES5
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE)
    INITIAL OF 160K
    ACCORDING TO 1 M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    DEFAULT USER_TABLES
    )
    NOLOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;

    This code works fine for all the files and all types (stores and retrieves the document in my web application), with the exception of files whose size is between 32768 and 65535 (2 ^ 15 and 2 ^ 16). On the files that are the size, this error is returned to the insertion:

    ORA-01460: dead letter or unreasonable conversion requested

    My version 11.1.0.6.0 Oracle Client is installed and the version of the Oracle.DataAccess.dll is 2.111.6.0. I know that this is not the latest version of the software, but software installation is difficult in my organization that we do not have admin privlidges. The .NET web application and this particular application is a 4.0 application web.

    I use a similar code of an MVC web application that sees the same results when the files came from an object HttpFileCollectionBase (Request.Files).

    What Miss me the code ODP.NET? My table should setting?

    Thank you very much for your time and help me with this!

    -Sean

    Suggestions for your ODP.NET code.
    1.
    using Oracle.DataAccess.Types;
    ...
    OracleBlob myBlob = new OracleBlob (con);
    myBlob.Write (Mon_tableau_octets, 0, count); where Mon_tableau_octets is filled by a file stream and count is the number of bytes to write to myBlob
    cmd parameters [0]. Value = myBlob;
    ...

    2. don't check that when he is not null, then have blob object, command object and a connection object. (No need to close the connection before eliminating)
    It is not relevant to the question.

    Edited by: shsu January 12, 2012 16:16

  • Error: «Please insert a blank disc into the CD drive (E :).» Once Windows Media Player detects a new disc, it will start automatically burning"

    Hi, we are currently running Windows XP SP3.  My daughter tries to download a song from Windows Media Player, she needs for her class dance.  It just download the song bad by accident without problem.  Now she's trying to download the song using the same CD (CD - R80) and it gives sound this error: «Please insert a blank disc in the CD drive (E :).» Once Windows Media Player detects a new disc, it will start automatically burning."  Someone please help.  She needs this to practice his senior dance solo.

    As I understand it, the CD was already burned once, and now she's trying to burn on the same CD again? This is not possible, as the CD - Rs can only be burned once. She will need a new blank CD - R, like the error message.

  • T4850CT: Error Message: "error HDC - insert system disk".

    Hello...

    Can anyone help? I think I know what the error message means... but don't know how to fix it. Any ideas? I am currently trying to find a system disk for this old laptop - online

    To start... the laptop has in his memory and displays this error message:

    Error HDC
    Insert system disk in drive

    I can access the configuration system and which seem to be about! ? The bar... it status QuickRead recognizes / active hard and floppy drive.

    Any help is appreciated completely ([email protected])

    Post edited by: anjasomething

    Hello

    Is it possible that the HARD disk is not recognized correctly?

  • Error in inserting data to the database

    I use SQL to store the data when I'm insterting the data in my table and then I get the error 2147217833.

    The image that is attached to the table structure and PROCESS as I am recording insterting. I use LV2011.

    I am able to connect to the database but error by inserting

    Soved. UerId 5 and I've been insterting 6.

  • Samsung SCX 4200 printer spooler service is not running"error; any attempt to add a local printer

    Samsung SCX 4200 printer spooler service is not running"error; any attempt to add a local printer

    For example, the print spooler runs?

    Type Services.msc in the box run from the start menu and check the parameters print spooler, set it to auto start.

    John

  • could not access a file. possible anti-virus protection is running. error (0x80070005)

    could not access a file. possible anti-virus protection is running. error (0x80070005)

    Try a system restore to a Date before the problem began.

    Restore point:

    http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-system-restore/

    Do Safe Mode system restore, if it is impossible to do in Normal Mode.

    Try typing F8 at startup and in the list of Boot selections, select Mode safe using ARROW top to go there > and then press ENTER.

    Try a restore of the system once, to choose a Restore Point prior to your problem...

    Click Start > programs > Accessories > system tools > system restore > choose another time > next > etc.

    http://www.windowsvistauserguide.com/system_restore.htm

    Read the above for a very good graph shows how backward more than 5 days in the System Restore Points by checking the correct box.

    See you soon.

    Mick Murphy - Microsoft partner

  • CC needs to update, but I get a message saying that another installer is running. (error 87)

    CC needs to update, but I get a message saying that another installer is running. (error 87)

    I'm on Windows 10 on PC

    Restart your computer and re-run the update.

  • Errors during insertion and update form using the VIEW.

    Here is my opinion:

    CREATE OR REPLACE FORCE 
    VIEW  "SH_ADD_EMPLOYEES_VW" ("EMP_ID", "DEPT_ID", "JOB_DESC_ID", "EMPNO", "EMP_FIRST", "EMP_LAST", "USER_NAME", "USER_INI", "DEPTNO", "DEPT_DESC", "ROLES_ID", "ADMIN", "CREATES", "APPROVES", "QUALITY", "CUST_SVC", "SH_LOCAL", 
    "SH_OFFICE", "SYSTEM") 
    AS
      select
    "SH_EMPLOYEES"."EMP_ID" as "EMP_ID",
    "SH_EMPLOYEES"."DEPT_ID" as "DEPT_ID",
    "SH_EMPLOYEES"."JOB_DESC_ID" as "JOB_DESC_ID",
    "SH_EMPLOYEES"."EMPNO"  as "EMPNO",
    "SH_EMPLOYEES"."EMP_FIRST" as "EMP_FIRST",
    "SH_EMPLOYEES"."EMP_LAST" as "EMP_LAST",
    "SH_EMPLOYEES"."USER_NAME" as "USER_NAME",
    "SH_EMPLOYEES"."USER_INI" as "USER_INI",
    "SH_EMPLOYEES"."DEPTNO" as "DEPTNO",
    "SH_EMPLOYEES"."DEPT_DESC" as "DEPT_DESC",
    "DOC_ROLES"."ROLES_ID" as "ROLES_ID",
    "DOC_ROLES"."ADMIN" as "ADMIN",
    "DOC_ROLES"."CREATES" as "CREATES",
    "DOC_ROLES"."APPROVES" as "APPROVES",
    "DOC_ROLES"."QUALITY" as "QUALITY",
    "DOC_ROLES"."CUST_SVC" as "CUST_SVC",
    "DOC_ROLES"."SH_LOCAL" as "SH_LOCAL",
    "DOC_ROLES"."SH_OFFICE" as "SH_OFFICE",
    "DOC_ROLES"."SYSTEM" as "SYSTEM"
    FROM "SH_EMPLOYEES" "SH_EMPLOYEES", "DOC_ROLES" "DOC_ROLES"
    where "SH_EMPLOYEES"."EMP_ID" = "DOC_ROLES"."EMP_ID"
    /
    
    

    Here's my trigger (note - I do not use the EXCEPTION clause or (declaration of it) because it throws an error msg = >: 'This is my message'.) Here, any help would be great as well.)

    CREATE OR REPLACE TRIGGER bi_ADD_EMPLOYEES_VW
    INSTEAD OF insert ON SH_ADD_EMPLOYEES_vw
    for each row
    declare
    duplicate_info EXCEPTION;
    PRAGMA EXCEPTION_INIT(duplicate_info, -00001);
    begin
    insert into SH_EMPLOYEES
    (EMP_ID, DEPT_ID, JOB_DESC_ID, EMPNO, EMP_FIRST, EMP_LAST, USER_NAME, USER_INI, DEPTNO, DEPT_DESC)
    values
    (:new.EMP_ID, :new.DEPT_ID, :new.JOB_DESC_ID, :new.EMPNO, :new.EMP_FIRST, :new.EMP_LAST, :new.USER_NAME, :new.USER_INI, :new.DEPTNO, :new.DEPT_DESC);
    insert into DOC_ROLES 
    (ROLES_ID, ADMIN, CREATES, APPROVES, QUALITY, CUST_SVC, SH_LOCAL, SH_OFFICE, SYSTEM)
    VALUES (
    :new.ROLES_ID, :new.ADMIN, :new.CREATES, :new.APPROVES, :new.QUALITY, :new.CUST_SVC, :new.SH_LOCAL, :new.SH_OFFICE, :new.SYSTEM);
    EXCEPTION
     WHEN duplicate_info THEN
      RAISE_APPLICATION_ERROR (
       num=> -20107
       msg=> 'Duplicate employee');
    END bi_ADD_EMPLOYEES_VW;
    /
    
    

    ERROR ON UPDATE:

    ORA-20505: DML error: p_rowid = 1001,.
    p_alt_rowid = EMP_ID, p_rowid2 = 2, p_alt_rowid2 = ROLES_ID. ORA-01779: cannot change
    a column that is mapped to a table not preserved key

    ERROR WHEN INSERTING:

    ORA-01400: cannot insert NULL in
    ("SPICE_HUNTER1". "" "" SH_EMPLOYEES '. "" EMP_ID") ORA-06512: at
    "SPICE_HUNTER1. BI_SH_ADD_EMPLOYEES_VW', line 3 ORA-04088: error during execution
    relaxing ' SPICE_HUNTER1. BI_SH_ADD_EMPLOYEES_VW' ORA-06512: at
    'SYS. WWV_DBMS_SQL', line 549 ORA-06512: at "APEX_040000.WWV_FLOW_DML", line 1121
    ORA-22816: feature not supported with RETURNING clause

    Error Impossible to process line on table SH_ADD_EMPLOYEES_VW

    I see you manage emp_id is null, you must assign a value if null sequence... This column cannot be null, where the error, and "Edit" a column of this table the DML to this id value.

  • Comment of "Syntax error in INSERT INTO statement." validation error.

    I had this working perfectly on MySQL. Then I was told that I had to do with a mdb database in Access, now the errors pop up like crazy. I fixed all of them except this one, I get a "syntax error in INSERT INTO statement." When I try to post a comment on a post in my mini-blog site.

    The thing is, I use almost the same code for the comments I make blog themselves. The positions work fine, the comments are not.

    He said that the error is on my page addcomment_process as 119. It is the following (line 119 is underlined, bold line is also bolded in the error message):

    < name cfquery = "input_comments."

    DataSource = "" #DSN # ""

    username = "" #DSNUSER # ""

    password = "#DSNPASS #" >

    INSERT INTO (comments)

    speaker,

    Comment,

    DateTime,

    post_id

    )

    VALUES)

    "#form.commenter #"

    "#form.comment #"

    "#form.datetime #"

    "#form.post_id #".

    )

    < / cfquery >

    It is all fine data, by simply inserting not, because it says:

    "INSERT INTO comments (speaker, comment, datetime, post_id) VALUES ('Anonymous', 'test commentary.', 25 April 12 22:55 ', ' 2').

    It worked perfectly, when it was a MySQL database, now I keep getting errors present a part of the site now that it is MDB. Anyone know what is happening?

    DateTime is a reserved word in Access.

    --

    Adam

  • Error when inserting XML file into a table in Oracle10g

    Hi team,

    I'm trying to insert an xml file into an Oracle 10g XMLType table. During the insertion, I get following error:

    ERROR on line 1:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS." DBMS_LOB", line 523
    ORA-06512: at "SYS." XMLTYPE", line 287
    ORA-06512: at line 1

    I did following steps.

    (1) create the DIRECTORY xml_dir as 'c:\xmldata ';

    (2) create table xmltab XMLType;

    The following packages are executed by schema 'Sys '.

    (1) dbmslob. SQL;
    (2) prvtlob. PLB;

    A xmldata folder is created under "c:\". "and with data_file.xml file is stored in it.

    After Insert stmt is executed that returns gives above error.

    Insert in xmltab values (XMLType (bfilename('xml_dir','data_file.xml'), nls_charset_id ('AL32UTF8')))


    Can you please give me a solution. It is very urgent.

    Thanks in advance.

    Kind regards
    Murielle

    After selecting the data in table xmltab I just got first line of the file xmldata. That is to say
    http://baro

    This must be a display problem.
    What client tool are you using and what version?

    If SQL * Plus, you won't see all content unless you set some options:
    {code}
    LONG VALUE
    SET LONGCHUNKSIZE
    {code}

    Could you try the following?
    {code}
    THE VALUE OF 10000 LONG

    SELECT t.object_value.getclobval () IN xmltab t;

    -to force printing:
    SELECT extract (t.object_value, ' / *'). getclobval() xmltab t;
    {code}

    Published by: odie_63 on 16 Feb. 2011 08:58

  • error when inserting the values too much or miss comma

    Hai All

    during the insertion, I got an error when inserting

    I have a table called T1 and declared as date I need to insert the current date and time in this column


    So I converted a varchar column and concat with time and iam trying to insert when inserting I got error


    insert into dail_att (respondent) values (to_date (to_char (attend_date, 'ddmmyyyy') |)) ("0815',"ddmmyyyy hh24");


    Concerning

    Srikkanth.M

    Hello
    Please let us know

    Desc dail_att;
    

    and the sample values in

    attend_date
    

    (There is also a ')' missing in your SQL, correct SQL would be

    INSERT INTO DAIL_ATT
                (INTIME
                )
         VALUES (TO_DATE (TO_CHAR (ATTEND_DATE, 'ddmmyyyy') || '0815',
                          'ddmmyyyy hh24'
                         )
                );
    

    * 009 *.

    Published by: 009 on March 18, 2010 21:23

  • Inserting BLOB into table

    HI, I am a newbie in PL/SQL, but I have a question about LOBs. My code below is to insert an image in a table. My question is, if I decide to return at a later date and perform my procedure once more to add another pict6.jpg at the table, would this procedure remove existing photos of the table and add only pict6.jpg? The reason I ask is because the update command line sets the column photo = empty_blob() every time that the anonymous block is run. If this is the case, what would be a better method to load images into a table? Thanks again for your time. My code is below, please excuse my notes, which I'm still learning:

    GRANT CONNECT, RESOURCE to scott;

    GRANT CREATE ANY DIRECTORY TO scott;

    GRANT DROP ANY DIRECTORY to scott;

    CREATE or CHANGE in ADPHOTO_DIR the DIRECTORY "C:\Temp".

    /

    GRANT READ ON DIRECTORY ADPHOTO_DIR to scott;

    CONNECT scott/tiger2;

    COMMIT;

    -ALTER TABLE StudentRecord ADD (Photograph BLOB); <-can be used instead of the below -.

    CREATE OR REPLACE StudentRecord TABLE

    (First name VARCHAR2 (20) not null,)

    LastName VARCHAR2 (40) not null,

    HomeworkAvg NUMBER (6.2),

    AttendanceAvg NUMBER (6.2),

    ExamAvg NUMBER (6.2),

    StudentID VARCHAR2 (10),

    Photographing the BLOB

    CONSTRAINT check_FirstName_LastName CHECK (FirstName! = LastName As String)

    );

    CREATE OR REPLACE PROCEDURE load_blob_from_file

    (p_photo VARCHAR2)

    AS

    f_photo BFILE.

    b_photo BLOB;

    BEGIN

    UPDATE StudentRecord SET photo = empty_blob()

    RETURN to photograph IN b_photo;

    f_photo: = bfilename ('ADPHOTO_DIR', p_photo);

    DBMS_LOB. FileOpen (f_photo, dbms_lob.file_readonly);

    DBMS_LOB. LoadFromFile (b_photo, f_photo, dbms_lob.getlength (f_photo));

    DBMS_LOB. FileClose (f_photo);

    commit;

    EXCEPTION

    WHILE others THEN

    dbms_output.put_line ('* ERROR * check your procedure.) ") ;

    end;

    /


    -Run the load_blob_from_file procedure to insert the first picture in the table StudentRecord

    EXECUTE load_blob_from_file ('pict1.jpg');

    commit;

    EXECUTE load_blob_from_file ('pict2.jpg');

    commit;

    EXECUTE load_blob_from_file ('pict3.jpg');

    commit;

    EXECUTE load_blob_from_file ('pict4.jpg');

    commit;

    EXECUTE load_blob_from_file ('pict5.jpg');

    commit;


    -Test to see if it worked

    SELECT FirstName, dbms_lob.getlength (Photograph) "Photo Size"

    OF StudentRecord;

    Your procedure works only if there is always exactly 1 row in the table of StudentRecord.  It seems highly unlikely - you probably wouldn't need store photos if your school takes care of a student.

    Your definition of the procedure does not seem particularly reasonable.  Of course, the goal is not to load a photo into the table, it must load the photo online of an individual to the student in the table.  This means that your procedure should take a parameter that identifies which student photography is and the name of the photo.  Normally, this would be the primary key of the table of StudentRecord.

    Your table of StudentRecord, however, has no keys.  It is a mistake.  Each table must have a primary key.  It does not appear that you have something that you could use as a natural key, we will create a synthetic key instead.

    CREATE OR REPLACE TABLE StudentRecord
         ( StudentID NUMBER PRIMARY KEY,
           FirstName VARCHAR2(20) not null,
           LastName VARCHAR2(40) not null,
           HomeworkAvg NUMBER(6,2),
           AttendanceAvg NUMBER(6,2),
           ExamAvg NUMBER(6,2),
           StudentID VARCHAR2(10),
           Photograph BLOB,
           CONSTRAINT check_FirstName_LastName CHECK (FirstName != LastName)
        );
    

    Once we do that, we can meaningfully define the procedure of the signature to the StudentID and the name of the image

    CREATE OR REPLACE PROCEDURE load_blob_from_file
      (p_studentID StudentRecord.StudentID%TYPE,
      p_photo VARCHAR2)
    

    Your UPDATE statement would then use the StudentID happened to determine which line to operate on a

    UPDATE StudentRecord
         SET Photograph = empty_blob()
    WHERE StudentID = p_StudentID
    RETURN Photograph INTO b_photo;
    

    That allows your procedure to work when there are multiple lines in the table of StudentRecord.  It will make the new photo of an individual student to replace the old photo of this student only if there is.

    Justin

  • Error updating a blob column

    Hello Hello everyone,

    first I created the directory images like "C:\images".

    then I created the table PRICUSTOMERPROOF

    Name of Type Null

    ------------------------ ---- ------------

    CUSTOMERID VARCHAR2 (50)

    IMAGEID NUMBER

    NUMBER OF IDTYP

    IDVALUE VARCHAR2 (50)

    IDEXPDATE TIMESTAMP (6)

    IDIMAGE BLOB

    ACTIVEC NUMBER (1)

    USERR VARCHAR2 (10)

    DATED TIMESTAMP (6)

    DEFAULTC NUMBER (1)

    NUMBER OF CUSTOMERIDENTIFICATIONID

    then I inserted all the values in the table except column IDIMAGE

    then I tried to update the column with

    DECLARE

    l_bfile BFILE.

    l_blob BLOB;

    BEGIN

    SELECT IDIMAGE

    IN l_blob

    OF PRICUSTOMERPROOF

    WHERE CUSTOMERID = "Pri29098."

    UPDATE;

    l_bfile: = BFILENAME (upper ('images'), "Tulips.jpg");

    DBMS_LOB. FileOpen (l_bfile, Dbms_Lob.File_Readonly);

    DBMS_LOB. LoadFromFile (l_blob, l_bfile, DBMS_LOB.getlength (l_bfile));

    DBMS_LOB. FileClose (l_bfile);

    END;

    When I run the codes I get

    Error report:

    ORA-22285: non-existent directory or file for FILEOPEN operation

    ORA-06512: at "SYS." DBMS_LOB", line 805

    ORA-06512: at the level of line 12

    22285 00000 - 'non-existent directory or file %s operation '.

    * Cause: Attempted access to a directory that does not exist, or attempted

    to access a file in a directory that does not exist.

    * Action: To ensure that an appropriate system specified

    the directory exists in the data dictionary, or

    Make sure that the name is correct.

    im sure that the directory of the image exists. can someone help me get errors deleted

    thanking you

    Prakash

    Good; After the granting of privileges, it is a different matter! To do this, you will need to initialize the variable of type blob with a value of type blob (use empty_blob()). Try it

    DECLARE
    l_bfile BFILE.
    l_blob BLOB;

    BEGIN
    / * commented
    SELECT IDIMAGE FROM l_blob
    OF PRICUSTOMERPROOF
    WHERE CUSTOMERID = "Pri29098."
    UPDATE; */
     
    Update pricustomerproof set idimage = empty_blob()
    where customerid = "Pri29098."
    return idimage in l_blob;
     
    l_bfile: = BFILENAME (upper ('images'), "Tulips.jpg");
    DBMS_LOB. FileOpen (l_bfile, dbms_lob.file_readonly);
    DBMS_LOB. LoadFromFile (l_blob, l_bfile, dbms_lob.getlength (l_bfile));
    DBMS_LOB. FileClose (l_bfile);
     
    commit;
    END;
    /

  • Inserting blob in a table: problems

    I wanted to insert a picture into the database using PLSQL table. Please let me know if the image file must be on a database server or I can insert it premises as well. Please find below my code and the error I get.

    Call to the procedure and the error
    BEGIN
    load_blob_from_file
    ( 'D:\PRoJeCt-RS\OracleError', 'item', 'item_blob',  'id', '2');
    END;
    
    BEGIN
    *
    ERROR at line 1:
    ORA-22285: non-existent directory or file for FILEEXISTS operation
    ORA-06512: at "SYS.DBMS_LOB", line 504
    ORA-06512: at "CMSRTPGM.LOAD_BLOB_FROM_FILE", line 18
    ORA-06512: at line 2
    My procedure to insert data into the table
    CREATE OR REPLACE PROCEDURE load_blob_from_file
    ( src_file_name     IN VARCHAR2
    , table_name        IN VARCHAR2
    , column_name       IN VARCHAR2
    , primary_key_name  IN VARCHAR2
    , primary_key_value IN VARCHAR2 ) IS
      -- Define local variables for DBMS_LOB.LOADCLOBFROMFILE procedure.
      des_blob      BLOB;
      src_blob      BFILE := BFILENAME('GENERIC',src_file_name);
      des_offset    NUMBER := 1;
      src_offset    NUMBER := 1;
      -- Define a pre-reading size.
      src_blob_size NUMBER;
      -- Define local variable for Native Dynamic SQL.
      stmt VARCHAR2(2000);
    BEGIN
      -- Opening source file is a mandatory operation.
      IF dbms_lob.fileexists(src_blob) = 1 AND NOT dbms_lob.isopen(src_blob) = 1 THEN
        src_blob_size := dbms_lob.getlength(src_blob);
        dbms_lob.open(src_blob,DBMS_LOB.LOB_READONLY);
      END IF;
      -- Assign dynamic string to statement.  -- We are going to obtain the clob locator (pointer) to use later 
      stmt := 'UPDATE '||table_name||' '
           || 'SET    '||column_name||' = empty_blob() '
           || 'WHERE  '||primary_key_name||' = '||''''||primary_key_value||''' '
           || 'RETURNING '||column_name||' INTO :locator';
      -- Run dynamic statement.  -- the locator (pointer) to the blob will assigned to des_blob   
      EXECUTE IMMEDIATE stmt USING OUT des_blob;
      -- Read and write file to BLOB, close source file and commit.
      dbms_lob.loadblobfromfile( dest_lob     => des_blob
                               , src_bfile    => src_blob
                               , amount       => dbms_lob.getlength(src_blob)
                               , dest_offset  => des_offset
                               , src_offset   => src_offset );
      -- Close open source file.
      dbms_lob.close(src_blob);
      -- Commit write and conditionally acknowledge it.
      IF src_blob_size = dbms_lob.getlength(des_blob) THEN
        $IF $$DEBUG = 1 $THEN
          dbms_output.put_line('Success!');
        $END
        ROLLBACK;
      ELSE
        $IF $$DEBUG = 1 $THEN
          dbms_output.put_line('Failure.');
        $END
        RAISE dbms_lob.operation_failed;
      END IF;
    END load_blob_from_file;
    The table structure
    CREATE TABLE ITEM
       (     "ID" NUMBER, 
         "TITLE" VARCHAR2(50), 
         "ITEM_BLOB" BLOB
       )
    Thanks in advance!
    Concerning
    34MCA2K2

    Published by: BluShadow on June 14, 2012 13:31
    addition of {noformat}
    {noformat} tags for readability.  Please read {message:id=9360002} and learn to do this yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    Yes,

    Start by creating an object directory point to a physical directory on the server database as the 'oracle '.
    user has read/write permissions.

    CONN / AS SYSDBA
    CREATE or REPLACE DIRECTORY nom_repertoire as 'D:\Applications ';
    GRANT READ, WRITE ON DIRECTORY NOM_REPERTOIRE TO USER_NAME;

    Here is the diagram user USER_NAME.

    Then,.
    create and populate a table to contain the images in the database your user to user schema.

    and try this procedure...

    DECLARE
      l_dir    VARCHAR2(10) := 'DIR_NAME';   ----> Is the Directory Object we created.
      l_file   VARCHAR2(20) := 'site_logo.gif';   ----- > The image to be located in the DB Server in the Directory Path DIR_NAME mentioned.
      l_bfile  BFILE;
      l_blob   BLOB;
    BEGIN
      INSERT INTO images (id, name, image)
      VALUES (images_seq.NEXTVAL, l_file, empty_blob())
      RETURN image INTO l_blob;
    
      l_bfile := BFILENAME(l_dir, l_file);
      DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
      DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
      DBMS_LOB.fileclose(l_bfile);
    
      COMMIT;
    END;
    

    Thank you
    Shankar

Maybe you are looking for