Process to Insert Image into table BLOB column

Process to Insert Image into table BLOB column

create  table testr13 (col1 blob);

/

select * from testr13;

/

create DIRECTORY testr13 as '\Rehman\Training\My docs';

/

DECLARE

    l_bfile BFILE;

    l_blob  BLOB;

BEGIN

    -- Initialize the BLOB column

    INSERT INTO testr13 (col1)

    VALUES (EMPTY_BLOB())

    RETURNING col1 INTO l_blob;


    -- Specify the location of the image file

    l_bfile := BFILENAME('XX_SHAREPOINT_TEST', 'm.jpg');


    -- Open the BFILE

    DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);


    -- Load the BFILE data into the BLOB column

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


    -- Close the BFILE

    DBMS_LOB.fileclose(l_bfile);

    

    -- Commit the transaction

    COMMIT;

END;

/


Comments

Popular posts from this blog

opaque schema xsd (standard file used in OIC)

SQL,PLSQL interview practice and DSA patterns

QR code Generate From Oracle PLSQL