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
C
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm#BABDDFDH
I think, D is correct…
I’ve executed this code and it works as it is, and when “lobloc CLOB := empty_clob();”
D
I think the select into already set address value to lob segments, never mind if it’s null or not
hi no, D is wrong
it may be B and C
it’s also true that non null values ( C ) include also an empty locator (B)
how could we answer so ? C or C and B ?
this is the demonstratio that D is wrong and B s right…
create table print_media
(
ADVT_ID NUMBER,
ADVT_SOURCE CLOB
);
insert into print_media values (1, null);
insert into print_media values (2, null);
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;
ORA-06502: PL/SQL: errore : invalid LOB locator specified: ORA-22275 di numero o valore
ORA-06512: a “SYS.DBMS_LOB”, line 1132
ORA-06512: a line 10
truncate table print_media
insert into print_media values (1, empty_clob());
insert into print_media values (2, empty_clob());
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;
select * from print_media
2 This is the second line of a new document
D is the right one
If advt_source is null for advt_id=2, above block will fail, so the value of advt_source is still now.
If advt_source is not null, maybe have more or less characters than buffer, so the value is not for sure.
sorry, C is the right one, as ‘above code to execute successfully’