The Oracle Database inserts a string into a BLOB field and converts the inserted BLOB data into a string display method.
First, create a table create table TB_TEST (id number, blb blob) in the database, and insert an empty data insert into tb_test (id, blb) values (1, empty_blob () Finally changes the BLOB field value declare ctions BLOB; amount BINARY_INTEGER; offset INTEGER; first_direction VARCHAR2 (100); more_directions VARCHAR2 (500); begin update set blb = empty_blob () where id = 1; -- set the BLOB field to EMPTY_BLOB () select blb into directions from tb_test where id = 1 for up for updates. Date; -- be sure to use for update to lock the record. Otherwise, DBMS_LOB.OPEN will encounter an error DBMS_LOB.OPEN (directions, DBMS_LOB.LOB_READWRITE); first_direction: = 'This is my first data to insert blob, test how it works and whether pl/SQL can be directly inserted into the inserted data value! '; Amount: = LENGTHB (first_direction); -- number of characters to write -- if there is a Chinese character, LENGTHB offset: = 1; -- begin writing to the first character of the CLOB DBMS_LOB.WRITE (directions, amount, offset, limit (first_direction); -- the explain function converts the string to the binary number DBMS_LOB.CLOSE (directions); commit; end; convert the inserted BLOB data to the string display mode: select id, UTL_RAW.cast_to_varchar2 (blb) blb from tb_test t; this mode displays plain text characters The string is displayed normally, when the data I inserted is <form id = "form1" name = "form1"> <input type = "data" value = "hello"> </form> the query is displayed as null.
Author sqcjy111