2012-12-20 10 views
6

Ho una procedura che popola una variabile BLOB con un documento PDF. Quello che sto cercando di fare è aggiungere la logica per visualizzare solo il documento PDF in un periodo di 60 giorni da una data statica. Vedere di seguito:Errore ORA-22275: localizzatore LOB non valido

check_staticdate  number(1); 

function DisplayPDF (audit in number) RETURN blob is 

person_id  person.person_id%type; 
z_lob   blob; 
blob_length NUMBER; 


CURSOR getPDF(audit number) IS 
    select report 
    from report_table 
    where report_type = 'PDF' 
    and job_no = audit order by rec_no; 


begin 

/* Check Valid ID */ 
if not package.ValidID(person_id, check_only=>TRUE) then 
    return z_lob; 
end if; 


/* Here is the case statement.*/ 
select case 
    when exists 
     (
     SELECT 'x' from table 
     where table_id = person_id 
     and trunc(sysdate) < trunc(table_static_date + 60) 
    ) 

    then 1 
    else 0 
    end into check_staticdate 
from dual; 


if (check_staticdate = 0) then 
    return z_lob; 
end if; 



open getPDF(audit); 
fetch getPDF into z_lob; 
close getPDF; 
return z_lob; 


end DisplayPDF; 

L'errore che sto ricevendo è: ORA-22275: invalid LOB locator specified.

Sono nuovo di Oracle SQL, e sono sicuro perché i miei ValidID controllo opere ritorno z_lob ma il mio caso dichiarazione non lo fa.

Edit: L'aggiunta di stack errori pieno

Failed to execute target procedure ORA-22275: invalid LOB locator specified 

ORA-06512: at "SYS.WPG_DOCLOAD", line 51 

ORA-06512: at "User.Package", line 733 

ORA-06512: at line 33 

risposta

16

inizializzare il tuo pallonetto con temporanea prima

DBMS_LOB.CREATETEMPORARY(z_lob,true); --true if you want it to be cached. 
+2

ho voluto fare in modo che hai credito per questo. Questo finì per essere riassegnato e riordinato come prioritario. Tuttavia, la tua risposta alla fine ha funzionato. Grazie! – Phoenix

+0

Insieme con 'DBMS_LOB.OPEN', come quella - ' DBMS_LOB.CREATETEMPORARY ( lob_loc => z_lob , cache => true , dur => dbms_lob.call); DBMS_LOB.OPEN ( lob_loc => z_lob , open_mode => DBMS_LOB.LOB_READWRITE); ' - e funziona. – PhistucK

0

La vostra funzione è probabilmente tornando (a seconda del valore del parametro audit) un blob con un valore NULL al metodo SYS.WPG_DOCLOAD, che genera l'eccezione non gestita che si vede.

Forse si potrebbe modificare la vostra return z_lob; di essere return nvl(z_lob, empty_blob());

Problemi correlati