Examine the structure of the PRINT_MEDIA table:
Name Null? Type
————— ——– ———
ADVT_ID NUMBER
ADVT_SOURCE CLOB
Examine the following PL/SQL block:
DECLARE
lobloc CLOB;
buffer VARCHAR2(100);
amount NUMBER;
offset NUMBER :=1;
BEGIN
buffer :=’This is the second line of a new document’;
amount := LENGTH(buffer);
SELECT advt_source INTO lobloc FROM print_media WHERE advt_id=2 FOR UPDATE;
DBMS_LOB.WRITE(lobloc,amount,offset,buffer);
COMMIT;
END;
/
What must be the value in the ADVT_SOURCE column for the above code to execute successfully?
A.
null
B.
an empty locator
C.
a non-NULL value
D.
either null or any non-NULL values
The “non-NULL” value as an answer is fine but if you try the following insert then run the code, it also works:
insert into print_media values (2,empty_clob());
http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions049.htm
I think answer “B” is exacly what EMPTY_CLOB() is for.
…for the above code to execute successfully..
If the record with ADVT_ID = 2 was not found, then it rise the exception NO_DATA_FOUND.
I think “С”.
C
If advt_source of ADVT_ID = 2 is null, above code will throw exception, then the value of advt_source is null;
If advt_source is not null and value length amount, the value will be buffer plus (original value without the 1st amount length characters).
So correct answer is D