Examine the structure of the TEST_DETAILS table:
Name Null? Type
————— ——– ———TEST_ID NUMBER
DESCRIPTION CLOB
DESCRIPTION data was entered earlier and saved for TEST_ID 12.
You execute this PL/SQL block to add data to the end of the existing data in the DESCRIPTION
column for TEST_ID 12:
DECLARE
clob_loc CLOB;
buf CHAR(12);
BEGIN
SELECT description INTO clob_loc FROM test_details WHERE test_id = 12 ;
buf := ‘0123456789’;
DBMS_LOB.WRITEAPPEND(clob_loc,DBMS_LOB.GETLENGTH(buf), buf);
COMMIT;
END;
/
It generates an error on execution.
What correction should you do to achieve the required result?
A.
WRITEAPPEND must be replaced with APPEND.
B.
The BUF variable data type must be changed to CLOB.
C.
FOR UPDATE must be added to the SELECT statement.
D.
The GETLENGTH routine must be replaced with the LENGTH built-in function in
WRITEAPPEND.
D?
http://docs.oracle.com/database/121/ARPLS/d_lob.htm#ARPLS66758
http://docs.oracle.com/database/121/ARPLS/d_lob.htm#ARPLS66709
D?
http://docs.oracle.com/database/121/ARPLS/d_lob.htm#ARPLS66758
docs.oracle.com/database/121/ARPLS/d_lob.htm#ARPLS66709
D is incorrect. C is valid.
Error:
Error report –
ORA-22920: row containing the LOB value is not locked
ORA-06512: at “SYS.DBMS_LOB”, line 1146
ORA-06512: at line 7
22920. 00000 – “row containing the LOB value is not locked”
*Cause: The row containing the LOB value must be locked before
updating the LOB value.
*Action: Lock the row containing the LOB value before updating the LOB
value.
Script:
insert into test_details values (12, ‘test’);
select * from test_details;
DECLARE
clob_loc CLOB;
buf CHAR(12);
BEGIN
SELECT description INTO clob_loc FROM test_details WHERE test_id = 12 /*for update*/ ;
buf := ‘0123456789’;
DBMS_LOB.WRITEAPPEND(clob_loc,DBMS_LOB.GETLENGTH(buf), buf);
COMMIT;
END;
C