Numeric or value error invalid lob locator specified ora 22275

clob to blob at some instance fails with PL/SQL: numeric or value error: invalid LOB locator specifi I am having an existing function to convert clob to blob as below — Description : Converts CLOB to BLOB function clob_to_blob (p_clob in clob) return blob is vOffset number default 1; vAmount number default 4096; vOffsetWrite […]

Содержание

  1. clob to blob at some instance fails with PL/SQL: numeric or value error: invalid LOB locator specifi
  2. Answers
  3. CONVERTTOBLOB Procedure

clob to blob at some instance fails with PL/SQL: numeric or value error: invalid LOB locator specifi

I am having an existing function to convert clob to blob as below

— Description : Converts CLOB to BLOB

function clob_to_blob (p_clob in clob) return blob is

vOffset number default 1;

vAmount number default 4096;

vOffsetWrite number default 1;

kProcedureName constant varchar2(61) := kMyPackage||’.clob_to_blob’;

dbms_lob.read(p_clob, vAmount, vOffset, vBuffer);

dbms_lob.write(vBlob, vAmountWrite, vOffsetwrite, utl_raw.cast_to_raw(vBuffer));

vOffsetWrite := vOffsetWrite + vAmountWrite;

vOffset := vOffset + vAmount;

when no_data_found then

when others then

sysmsg.add_error_msg(sysmsg.g_event_id, kProcedureName, sqlerrm, sqlcode);

‘Unable to read CLOB (bytes read: ‘||vAmountWrite||’, offset: ‘||vOffsetwrite||’)’);

At what instance can this fail with PL/SQL: numeric or value error: invalid LOB locator specified

Answers

. How is the function being called when it fails?

. Are dblinks involved?

. Are connection pools involved?

. How long does the function take to fail?

. What database version or versions are involved?

. Are all databases involved Oracle database?

. Does it work under different circumstances?

. Does it ever work?

. Can you copy/paste a real errorstack from a failure or is the title the whole errorstack verbatim?

You may be focused on the wrong error in the errors you posted. There is an ORA-22 that is listed in the title.

00022, 00000, «invalid session ID; access denied»

// *Cause: Either the session specified does not exist or the caller

// does not have the privilege to access it.

// *Action: Specify a valid session ID that you have privilege to access,

// that is either you own it or you have the CHANGE_USER privilege.

Two MAJOR problems with what you posted:

First — get rid of this GARBAGE so Oracle can properly report any exceptions

Second — if you had just read the Oracle docs BEFORE you try to use Oracle functionality you would find Oracle ALREADY HAS that function.

So there is no need to write your own.

In the future PLEASE RTFM when you want to learn about Oracle functionality.

CONVERTTOBLOB Procedure

Then if you read the spec for the ‘amount’ parameter you will find this:

No need to reinvent the wheel.

No need for any looping.

BIG NEED to read the docs.

Sorry for not posting entire detail

Version is Oracle Database 12c Standard Edition Release 12.1.0.2.0

How long does the function take to fail? — This is immediately reflected in Front end Oracle APex which calls view

All database involved are Oracle databases across schemas defined as views

Function is called from view like schema.package.function as below

Yes it works for certain set of organisations and fails for others while debugging found when commenting clob_to_blob(csv_CLOBContent) it works. Hence arrived this will be the issue. Still trying to find out why this fails for specific organisations.

(case when (csv_FileName is not null) then . . .

ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275

It is called in Oracle apex as

when 0 then null

from — This view is defined in top portion

This is an existing code which is being maintained and hence not created anything new

This is working most of the times but when it fails at some times for some ofthe organisation unable to really debug what causes the entire issue

There are 2 different exceptions reported:

ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275

This is likely the root error and caused by passing an invalid LOB pointer (aka locator) to the function.

ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML

This is likely caused by your calls in the exception handler to the error logging package, which does DML into error log table(s).

. so there’s a typo in the title then. No ORA-22 in actual error stack. *sigh*

The unmodified error stack will give you line numbers that raised each part of the error stack, this removes all guessing so why are you deciding to swallow it?

Scrap the when others then.. or reraise the original error stack at the end of it (But if you are going do to that, make sure the calls you are doing in the exception handling are actually legal to make, it very much sounds like they’re not)

I suspect your code fails for the following reasons.

An exception is occurring in conversion for some reason. It isn’t a no data found one, so hits the when others. This logs data and calls commit, which causes ORA-14552, as you can’t commit whilst running a select or other DML, for a very good reason, default transaction isolation is read committed, meaning data could change, which breaks the ACID model.

The transaction issue causes your temporary lob locator to be invalid.

Solution, remove the WHEN OTHERS. sysmsg rubbish, or use the DBMS_LOB version rp suggests, you’ll see what the problem is. Other possible solution is to make the sysmsg transaction autonomous, which it should be anyway.

I have no idea what that means or why you think it is relevant.

That ‘existing code’ has a bug. The only way to fix that bug is to fix the code.

The BEST way to fix the code is to use Oracle’s function to do the conversion.

What is it that isn’t clear about that?

If you have some plan to fix the code without modifying it we would all be very interested in how you think you can do that.

What ’causes the entire issue’ is that someone chose to write their own function (and did a VERY POOR job of it) when Oracle already has one and provides support for it.

Even if you needed to use a function with that same name and signature the TRIVIAL solution is to replace the body of the function with a simple call to the Oracle supplied function.

Then the calling code won’t know the difference and there will be NOTHING to ‘debug’.

Источник

  • ORA-22275 :invalid LOB locator specified error while loading BLOBs/CLOBS.

    Hello All,
    I am trying to load BLOB/CLOB data from a client oracle DB to the oracle db on our side,we are using ODI version 10.1.3.5.6,which reportedly has the issue of loading BLOB/CLOBS solved.I am using
    The extraction fails in the loading stage when inserting data into the C$ table with the following error.
    «22275:99999 :java.sql.BatchUpdateException:ORA-22275:Invalid LOB locator specified».
    Kindly let me know how I can resolve this issue as the requirement to load this data is very urgent.
    Thanks,
    John

    One alternate way can be done out of ODI as ODI is still not able to resolve this issue. You can trim these fields (CLOB/BLOB) and push this data as separate fields into ODI and at the reporting end you can again concatenate them.
    May be this may solve your problem ….it solved mine.
    —XAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • DBMS_LOB.ISOPEN throws the error ora-22275 invalid lob locator

    DBMS_LOB.ISOPEN throws the error below error.
    ora-22275 invalid lob locator
    The below assume that i am getting the v_lob_length as empty. But i am getting error when it comes to DBMS_LOB.ISOPEN.
    Please correct me if i am wrong.
    here is my code:
    DBMS_LOB.createtemporary(v_xml_clob, TRUE);
    DBMS_LOB.open(v_xml_clob, DBMS_LOB.lob_readwrite);
    SELECT  DBMS_XMLGEN.getxml (‘SELECT object_name, object_type from dba_objects where rownum <= 5’)
    INTO    v_xml_clob
    FROM    DUAL;
    v_lob_length    := NVL(DBMS_LOB.getlength(v_xml_clob),0);
    v_index       := 1;
    fnd_file.put_line(fnd_file.log,’v_lob_length : ‘||v_lob_length);
    WHILE v_index <= v_lob_length
    LOOP
        v_read_cnt   := 32767;
        DBMS_LOB.read (
              v_xml_clob,
              v_read_cnt,
              v_index,
              v_chunk
        fnd_file.put(fnd_file.output,v_chunk);
        v_index := v_index + v_read_cnt;
    END LOOP;
    IF DBMS_LOB.ISOPEN(v_xml_clob) = 1
    THEN
        DBMS_LOB.close(v_xml_clob);
        DBMS_LOB.freetemporary(v_xml_clob);
    END IF;

    Most likely v_xml_clob is NULL so you’d rather check IF v_xml_clob IS NOT NULL AND DBMS_LOB.ISOPEN(v_xml_clob) = 1
    THENbye
    TPD

  • ORA-22275: invalid LOB locator specified

    Hello,
    I use Oracle 11.2.0.3. APEX 4.2.2… Listener 2.0.3 …. Glassfish server 4.0.
    When I run this procedure ( that is used in this tutorial )
    I get ORA-22275: invalid LOB locator specified.
    The error persists over Glass fish 3.0.2, Listener 2.0.1 and 2.0.2.
    Also, I installed this patch 16803775, but to not avail.
    declare
            v_mime  VARCHAR2(48);
            v_length  NUMBER;
            v_file_name VARCHAR2(2000);
            Lob_loc  BLOB;
    BEGIN
            SELECT MIMETYPE, CONTENT, filename,DBMS_LOB.GETLENGTH(content)
                    INTO v_mime,lob_loc,v_file_name,v_length
                    FROM image
                    WHERE id = 70;
                     htp.init;
                  — set up HTTP header
                        — use an NVL around the mime type and
                        — if it is a null set it to application/octect
                        — application/octect may launch a download window from windows
                        owa_util.mime_header( nvl(v_mime,’application/octet’), FALSE );
                    — set the size so the browser knows how much to download
                    htp.p(‘Content-length: ‘ || v_length);
                    — the filename will be used by the browser if the users does a save as
                    htp.p(‘Content-Disposition:  attachment; filename=»‘||replace(replace(substr(v_file_name,instr(v_file_name,’/’)+1),chr(10),null),chr(13),null)|| ‘»‘);
                    — close the headers  
                    owa_util.http_header_close;        
                    owa_util.http_header_close;
                    — download the BLOB
                    wpg_docload.download_file( Lob_loc );
    end  ;
    Any help pls, in getting that procedure works ?
    Regards,
    Fateh

    replace this statement
    select empty_clob() into c_xml from dual for update;
    with
    dbms_lob.createtemporary(c_xml, TRUE);

  • ORA-22275: invalid LOB locator specified on trigger

    I have a trigger which copies a blob on insert to one table to another.
    CREATE OR REPLACE TRIGGER SWZTPRO.TSWTMPI_BEFORE_INSERT
    BEFORE INSERT
    ON SWZTPRO.TO_TSWTMPI
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    discriminator TO_TSWCRUL.BTC_DIS%TYPE;
    discriminator:=:NEW.BTC_DIS;
    insert into …..
    If using after insert this triggerworks, but if the trigger fails for any reason, the client does not recieve the error.
    If using before insert this fails:
    insert into table, use before insert trigger
    ORA-22275: invalid LOB locator specified
    ORA-06512: at «SWZTPRO.TSWTMPI_BEFORE_INSERT», line 108
    ORA-22275: invalid LOB locator specified
    ORA-04088: error during execution of trigger ‘SWZTPRO.TSWTMPI_BEFORE_INSERT’
    Any help would be appreciated

    I have also used a varaiation tirgger to do an instead of on insert on a view and I get the following error:
    ORA-25008: no implicit conversion to LOB datatype in instead-of trigger

  • ORA-22275: invalid LOB locator specified in a function

    Hello all!!!
    I am having a little problem with a function that returns a blob… When I call the function, I get that error… Here is the function (I took all the exception management code to clear it up a little…)
    <CODE>
    FUNCTION f_getfileblob (p_id IN NUMBER,
    p_application IN VARCHAR2,
    p_subject IN VARCHAR2)
    RETURN BLOB
    IS
    v_table_name VARCHAR2(50);
    v_sql_string VARCHAR2(1000);
    lobfile BLOB := empty_blob();
    v_error NUMBER;
    BEGIN
    SELECT TABLE_NAME INTO v_table_name FROM ORACLE_TEXT_FILE WHERE APPLICATION = p_application AND SUBJECT = p_subject;
    v_sql_string := ‘SELECT FILE_BLOB FROM ‘ || v_table_name || ‘ WHERE id = :1’;
    EXECUTE IMMEDIATE v_sql_string INTO lobfile USING p_id;
    RETURN lobfile;
    END;
    </CODE>
    So, in this function, the first select is to find the name of the table in which I store my blobs (I’m trying to do something generic and cross application). Once I have that name, I can do the select of the blob. I can only use dynamic SQL because of the table name that is not known in advance.
    I tried this function with
    DBMS_LOB.CREATETEMPORARY(LOBFILE, TRUE, DBMS_LOB.CALL);
    to create the lob at the begining, but this returns another error… (i tried with and without the initialisation of the blob, empty_blob())
    ORA-24801: illegal parameter value in OCI lob function. But I don’t even know if it would help…
    Can somebody please help me?
    Thanks and best regards
    Neil.

    Sorry about that, error came from elsewhere…
    Thanks anyway
    Best regards
    Neil.

  • ORA-22275: invalid LOB locator specified problem

    Hi
    Can anybody point me in the right direction.. I am NOT using clob and blob anywhere in my operation.. All I am doing is plain inserts from arrays.. and it gives me this error.
    Here is the code:
    Connection conn = null;
              Statement stmt = null;
              PreparedStatement ps = null;
              CallableStatement cs= null;
              ResultSet rs = null;
              Connection conn1 = null;
              Statement stmt1 = null;
              CallableStatement cs1= null;
              ResultSet rs1 = null;
    conn = DataSrc.getDataSource().getConnection();
                   stmt =conn.createStatement();
                   conn1 = DataSrc.getDataSource().getConnection();
                   stmt1 =conn1.createStatement();
                   rs = stmt.executeQuery(sql1);
                   while (rs.next()) {
                        var10 = rs.getString(1);                    
                   cs=conn.prepareCall(«{call proc1}»);
                   cs.execute();
                   cs.close();
                   stmt = conn.createStatement();
                   ps = conn.prepareStatement(sql);
                   for (int pl = 0; pl < ij; pl++) {
                        var2 = array1[pl];
                        var3 = array2[pl];
                        var4 = array3[pl];
                        var5 = array4[pl];
                        var6 = “ABC”;
                        var7 = “ABC”;
                        var8 = array8[pl];
                        var9 = “ABC”;
                        var1 = var2.substring(0,6);
                        var2 = var2.substring(var2.length()-1);
                        var3 = var3.replace(«‘»,»»);
                        if (var9.length()<5) {
                             var9 = «00» + var9;
                        if (var9.length()<6) {
                             var9 = «0» + var9;
                        String sql2 = «xxxxxx»;
                        rs1 = stmt1.executeQuery(sql2);
                        while (rs1.next()) {
                             var11 = rs1.getString(1);                    
                                            if (!var2.equals(var8)) {
                             ps.setString(1, var1);
                             ps.setString(2, var2);
                             ps.setString(3, var3);
                             ps.setString(4, var4);
                             ps.setString(5, var5);
                             ps.setString(6, var6);
                             ps.setString(7, var7);
                             ps.setString(8, var8);
                             ps.setString(9, var9);
                             ps.setString(10, var10);
                             ps.setString(11, var11);
                             ps.executeUpdate();
                   ps.close();
                   cs=conn.prepareCall(«{call xxxxxxxxx}»);
                   cs.execute();
                   cs.close();               
                   stmt.executeUpdate(«COMMIT»);
                   stmt.close();
                   conn.close();
                   rs1.close();
                   stmt1.close();
                   conn1.close();

    cs=conn.prepareCall(«{call proc1}»);
    cs=conn.prepareCall(«{call xxxxxxxxx}»);check those procedures, might be invloved clob and blob operation….

  • ORA-22275 Invalid lob locator when using CLOB from a view

    Hi,
    I am having problems when passing a CLOB from a «Union all» view to a function. I get an ORA-22275 error when trying to construct an XmlType from the CLOB and
    the CLOB originates from a view. If the CLOB originates from a table, eveyting works fine. Here is the code, that reproduces the problem
    CREATE TABLE testclob
        (field1                         CLOB)
    — insert some data
    insert into testclob values (‘<a/>’);
    — Define a clob view over some tables
    create or replace view v_testclob
    (field1)
    as
    select field1 from testclob
    union all
    select field1 from testclob; — in reallity I use different tables
    — Creat a functions that proceses the CLOB
    CREATE OR REPLACE
    function MyFunction(v_myClob clob) return VARCHAR2
    IS
       myXML XMLTYPE;
    BEGIN
      select xmltype(v_myClob) into myxml from dual; — the view crashes ** HERE **
      — code ommited
      return ‘some data’;
    END;
    — Try to use the function:
    — Selecting from a table works OK
    select myfunction(field1) from testclob;
    — Selecting from the view crashes
    select myfunction(field1) from v_testclob;
    Error: ORA-22275: invalid LOB locator specified ORA-22275: invalid LOB locator specified ORA-06512: at «D_TEST.MYFUNCTION», line 6
    — I using the following version:
    select * from v$version;
    — Oracle9i Enterprise Edition Release 9.2.0.1.0 — Production      
    — PL/SQL Release 9.2.0.1.0 — Production                           
    — CORE     9.2.0.1.0     Production                                       
    — TNS for 32-bit Windows: Version 9.2.0.1.0 — Production          
    — NLSRTL Version 9.2.0.1.0 — Production The only workaround I have found is to use substr
      select xmltype(dbms_lob.substr(v_myClob)) into myxml from dual; — workaround.. but this mght trucnate my data.
    What am I doing wrong?
    Matej

    You need to apply the latest patchset for your version of the database on your version of the operating system:
    SQL> CREATE TABLE testclob
      2      (field1                         CLOB)
      3
    SQL> /
    Table created.
    SQL>
    SQL> — insert some data
    SQL> insert into testclob values (‘<Data>Testing</Data>’)
      2  /
    1 row created.
    SQL>
    SQL> — Define a clob view over some tables
    SQL>
    SQL> create or replace view v_testclob
      2  (field1)
      3  as
      4  select field1 from testclob
      5  union all
      6  select field1 from testclob
      7  /
    View created.
    SQL>
    SQL> — Creat a functions that proceses the CLOB
    SQL>
    SQL> CREATE OR REPLACE
      2  function MyFunction(v_myClob clob) return VARCHAR2
      3  IS
      4     myXML XMLTYPE;
      5  BEGIN
      6
      7    select xmltype(v_myClob) into myxml from dual; — the view crashes ** HERE **
      8    — code ommited
      9    return ‘some data’;
    10  END;
    11
    12  /
    Function created.
    SQL> — Try to use the function:
    SQL> — Selecting from a table works OK
    SQL> select myfunction(field1) from testclob;
    MYFUNCTION(FIELD1)
    some data
    SQL>
    SQL>
    SQL> — Selecting from the view crashes
    SQL> select myfunction(field1) from v_testclob;
    MYFUNCTION(FIELD1)
    some data
    some data
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 — Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.7.0 — Production
    SQL>

  • ORA-22275 invalid LOB locator

    I’ve tried to append couple of BLOB fields from one table and then update it to a record in another table. I got the following error. Does anyone know why?
    CHECK POINT 1
    begin
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified:
    ORA-22275
    ORA-06512: at «SYS.DBMS_LOB», line 753
    ORA-06512: at «RBSSDEV.PG_TB_COMMENT_DETAIL», line 57
    ORA-06512: at line 2
    My store procedure is :
    PROCEDURE SP_Insert_Comment_Detail
    ( v_CommentOID IN TB_COMMENT_DETAIL.COMMENTOID%TYPE ,
    v_DBName IN TB_COMMENT_DETAIL.DBNAME%TYPE ,
    v_ApplicationOID IN TB_COMMENT_DETAIL.APPLICATIONOID%TYPE ,
    v_Comments IN TB_COMMENT_DETAIL.COMMENTS%TYPE ,
    v_Created IN TB_COMMENT_DETAIL.CREATED%TYPE ,
    v_UserID IN TB_COMMENT_DETAIL.USERID%TYPE
    IS
    lv_CommentsBlob BLOB := EMPTY_BLOB;
    lv_CommentBlob BLOB := EMPTY_BLOB;
    lv_NewComment VARCHAR2(1) := ‘N’;
    CURSOR CommentDetail_cur IS
    SELECT Comments
    FROM TB_COMMENT_DETAIL
    WHERE CommentOID = v_CommentOID
    ORDER BY RecDate, DBName;
    CURSOR Comment1_cur IS
    SELECT Comments
    FROM COMMENT1
    WHERE CommentOID = v_CommentOID FOR UPDATE;
    BEGIN
    DBMS_LOB.CreateTemporary(lv_CommentBlob, TRUE, DBMS_LOB.CALL);
    OPEN CommentDetail_cur;
    FETCH CommentDetail_cur INTO lv_CommentBlob;
    IF CommentDetail_cur%NOTFOUND THEN
    lv_NewComment := ‘Y’;
    END IF;
    CLOSE CommentDetail_cur;
    INSERT INTO TB_COMMENT_DETAIL
    (CommentOID, RecDate, DBName, ApplicationOID,
    Comments, Created, UserID)
    VALUES
    (v_CommentOID, SYSDATE, v_DBName, v_ApplicationOID,
    v_Comments, v_Created, v_UserID);
    IF lv_NewComment = ‘Y’ THEN
    INSERT INTO Comment1
    VALUES (v_CommentOID, v_ApplicationOID, v_Comments, v_Created, v_UserID);
    COMMIT;
    ELSE
    DBMS_LOB.CreateTemporary(lv_CommentBlob, TRUE, DBMS_LOB.CALL);
    DBMS_LOB.CreateTemporary(lv_CommentsBlob, TRUE, DBMS_LOB.CALL);
    OPEN Comment1_cur;
    FETCH Comment1_cur INTO lv_CommentsBlob;
    — Empty the Comments field of the Comment1 table
    IF Comment1_cur%FOUND THEN
    DBMS_OUTPUT.PUT_LINE(‘CHECK POINT 1’);
    DBMS_LOB.TRIM(lv_CommentsBlob, 0);
    DBMS_OUTPUT.PUT_LINE(‘CHECK POINT 2’);
    END IF;
    OPEN CommentDetail_cur;
    LOOP
    FETCH CommentDetail_cur INTO lv_CommentBlob;
    EXIT WHEN CommentDetail_cur%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(‘CHECK POINT 3’);
    DBMS_LOB.APPEND(lv_CommentsBlob, lv_CommentBlob);
    DBMS_OUTPUT.PUT_LINE(‘CHECK POINT 4’);
    END LOOP;
    COMMIT;
    CLOSE Comment1_cur;
    CLOSE CommentDetail_cur;
    END IF;
    END SP_Insert_Comment_Detail;

    Sorry about that, error came from elsewhere…
    Thanks anyway
    Best regards
    Neil.

  • DBMS_LOB.CONVERTTOBLOB invalid LOB locator specified: ORA-22275

    Hi all,
    the following code has been working great on 11g (and apex.oracle.com)
    now when I try to use this function under 10g XE
    I get following error :
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    ORA-06512: at «SYS.DBMS_LOB», line 696
    ORA-06512: at «RIGHTSHOP.C2B», line 14line 14 being the line with DBMS_LOB.CONVERTTOBLOB
    any ideas ?
    CREATE OR REPLACE FUNCTION c2b( p_clob IN CLOB )
          RETURN BLOB
    is
      temp_blob   BLOB;
      dest_offset NUMBER  := 1;
      src_offset  NUMBER  := 1;
      amount      INTEGER := dbms_lob.lobmaxsize;
      blob_csid   NUMBER  := dbms_lob.default_csid;
      lang_ctx    INTEGER := dbms_lob.default_lang_ctx;
      warning     INTEGER;
    BEGIN
    DBMS_LOB.CREATETEMPORARY(lob_loc=>temp_blob, cache=>TRUE);
      DBMS_LOB.CONVERTTOBLOB(temp_blob, p_clob,amount,dest_offset,src_offset,blob_csid,lang_ctx,warning);
      return temp_blob;
    END;Kr
    Martin

    Can’t reproduce
    SQL> CREATE OR REPLACE FUNCTION c2b( p_clob IN CLOB )
    RETURN BLOB
    is
    temp_blob BLOB;
    dest_offset NUMBER := 1;
    src_offset NUMBER := 1;
    amount INTEGER := dbms_lob.lobmaxsize;
    blob_csid NUMBER := dbms_lob.default_csid;
    lang_ctx INTEGER := dbms_lob.default_lang_ctx;
    warning INTEGER;
    BEGIN
    DBMS_LOB.CREATETEMPORARY(lob_loc=>temp_blob, cache=>TRUE);
    DBMS_LOB.CONVERTTOBLOB(temp_blob, p_clob,amount,dest_offset,src_offset,blob_csid,lang_ctx,warning);
    return temp_blob;
    END;  2    3    4    5    6    7    8    9   10   11   12   13   14   15   16 
    17  /
    Function created.
    SQL> declare
      2     b blob;
      3     c clob;
      4  begin
      5     c := ‘x’;
      6     b := c2b (c);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SQL> and my version (also XE)
    SQL> select *
      2    from v$version
      3  /
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 — Product
    PL/SQL Release 10.2.0.1.0 — Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 — Production
    NLSRTL Version 10.2.0.1.0 — Production

  • ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified:

    «ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275»
    I use the procedure to convert the documents if it is not already converted before using procedure as follows
    PROCEDURE «STARDOC».»HTMLOUTPUT» (
    «DOCID» IN NUMBER) IS
    mklob clob;
    doccount number;
    errorcode number;
    errormessage varchar2(200);
    BEGIN — executable part starts here
    SELECT COUNT(document_id) INTO doccount FROM docviewhtml where document_id=docid;
    —dbms_output.put_line(doccount);
    if doccount=0 then
         dbms_output.put_line(‘Document Not Found: Converting ‘||docid);
         —If document is not found run document coversion routine
         ctx_doc.filter(‘idxdocuments’,docid, mklob,FALSE);
         INSERT INTO docviewhtml(document_id, html) VALUES (docid, mklob);
         COMMIT;
    elsif doccount=1 then
         —return;
         dbms_output.put_line(‘Document Found’);
         —if document id found then return the document content
         null;
    else
         —dbms_output.put_line(‘Error occured’);
         —need to deal with duplicate documents
         null;
    end if;
    dbms_lob.freetemporary(mklob);
    EXCEPTION
    —rollback when an exception occurs
         WHEN OTHERS THEN
              errorcode:=SQLCODE;
              errormessage:=SQLERRM;     
              dbms_output.put_line(sqlcode || ‘:’ ||sqlerrm);
              ROLLBACK;
              LOGERROR(errorcode,errormessage);
    END «HTMLOUTPUT»;
    i get the error when i convert large documents
    «ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275»
    what is wrong. please help!

    «ORA-06502: PL/SQL: numeric or value error: invalid
    LOB locator specified: ORA-22275″
    PROCEDURE «STARDOC».»HTMLOUTPUT» (
    «DOCID» IN NUMBER) IS
    mklob clob;
         ctx_doc.filter(‘idxdocuments’,docid, mklob,FALSE);
    INSERT INTO docviewhtml(document_id, html) VALUES (docid, mklob);I think You forget to initialize variable mklob.
    You can do it, assigning the empty_clob().

  • IR: ORA-20001: get_dbms_sql_cursor error ORA-00904: : invalid identifier

    Hi everyone,
    has anyone else had this error which has been driving me round the bend during the last three days?
    I have an interactive report which used to work fine.
    Now it happens (when the page loads/a filter is en- or disabled) that — from time to time, but unpredictable — I receive
    ORA-20001: get_dbms_sql_cursor error ORA-00904: : invalid identifier
    The report is based on a table function.
    I will try to set up a testcase and post the link here, but so far I haven’t managed to force the error to occur.
    But maybe someone else has already bumped into this kind of error? I would be grateful for any hints!
    Best regards,
    Sabine
    Application Express 4.1.0.00.32
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 — 64bit Production

    Hi Jari,
    I changed the type definition (the return type of the table function) and extended the select list in the source of the IR.
    I do not use ‘select *’ but reference every column explicitly. So APEX easked me whether to add the new column.
    I also tried deleting in recreating the region, but no luck.
    Any more ideas?
    Best regards,
    Sabine

  • ERROR: ORACLE prepare error: ORA-00936: missing expression

    Hello,
    I am required to run «pass-through» Oracle SQL, to extract data from tables into SAS for processing and manipulation. My code (attached) reads and writes (executes) but with zero records to test first. I cannot get past the Prepare Error.
    The query is very much like other queries that seem to work, but I cannot get past this prepare error. I have no other access to individauls with adequate knowledge of PL SQL, and as a last stop hoped others in the forum could quickly spot the source of errror.
    Thanks very much in advance for any assistance.
    Jeff
    1 ;*’;*»;*/;quit;run;
    2 OPTIONS PAGENO=MIN;
    3 %LET _CLIENTTASKLABEL=%NRBQUOTE(rx_biplr_v3_2);
    4 %LET _EGTASKLABEL=%NRBQUOTE(rx_biplr_v3_2);
    5 %LET _CLIENTPROJECTNAME=%NRBQUOTE();
    6 %LET _SASPROGRAMFILE=;
    7
    8 ODS _ALL_ CLOSE;
    NOTE: Some of your options or statements may not be supported with the Activex or Java series of devices. Graph defaults for these
    drivers may be different from other SAS/GRAPH device drivers. For further information, please contact Technical Support.
    9 OPTIONS DEV=ACTIVEX;
    10 FILENAME EGHTML TEMP;
    NOTE: Writing HTML(EGHTML) Body file: EGHTML
    11 ODS HTML(ID=EGHTML) FILE=EGHTML ENCODING=’utf-8′ STYLE=EGDefault
    11 ! STYLESHEET=(URL=»file:///C:/Program%20Files/SAS/Shared%20Files/BIClientStyles/EGDefault.css»)
    11 ! ATTRIBUTES=(«CODEBASE»=»http://www2.sas.com/codebase/graph/v91/sasgraph.exe») NOGTITLE NOGFOOTNOTE GPATH=&sasworklocation
    11 ! ;
    12
    13 %gaccessible;
    14 /********************************************************/
    15 * RX_BIPLR_V3.SAS ;
    16 /********************************************************/
    17
    18 dm ‘log;clear;out;clear’;
    19 options linesize =120;
    20 Option obs=0 NoReplace;
    21
    22 ****************************************************************************************;
    23 *Date Programmer Reviewed By WHAT WAS DONE;
    24 *—— ————— ———— ——————————————;
    25 *2005 David Boyd Program creation for test population;
    26 *;
    27 *02/06/2006 Ivon Jones Modified to include total population;
    28 *;
    29 *07/20/2006 Ivon Jones Identified data elements for exclusion;
    30 * or inclusion for consolidation with ;
    31 * Robin’s report;
    32 *;
    33 *08/18/2006 Ivon Jones Updated the Specific Therapeutic Classes;
    34 * 10-2009 J Shaf — modified to extract actual or potential Bipolar Dx from UBH and Medical Claims;
    35 ****************************************************************************************;
    36
    37
    38
    39 *%let allclmorgn = (‘M’,’A’) ; /* all claims origin code */
    40 %let begdate=’01SEP2009’d;
    41 %let enddate=’30SEP2009’d;
    42 %let q = %str(%’) ;
    43
    44
    45 data _null_ ;
    46 call symput(‘fdos’,put(intnx(‘month’,»&begdate»d,-27,’beginning’), date9.) ) ;
    47 call symput(‘ldos’,put(intnx(‘month’,»&enddate»d,-0,’ending’), date9.) ) ;
    48 run ;
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    2 The SAS System 11:44 Friday, October 30, 2009
    cpu time 0.01 seconds
    49
    50
    51
    52 **************************************************************;
    53 * ??Use the data _null_ step to create a macro variable for the ;
    54 * year and month based on the ldos macro variable in the data ;
    55 * step above?? ;
    56 **************************************************************;
    57
    58
    59 data _null_ ;
    60 if month(«&ldos»d) < 10
    61 then call symput(‘yr_mo’,compress(year(«&ldos»d) || ‘0’ || month(«&ldos»d) ) ) ;
    62 else call symput(‘yr_mo’,compress(year(«&ldos»d) || month(«&ldos»d) ) ) ;
    63 run ;
    NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
    61:39 61:64 62:39 62:57
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    cpu time 0.00 seconds
    64
    65 *%put &biplr_dx;
    66 %put &begdate ;
    ’01SEP2009’d
    67 %put &enddate ;
    ’30SEP2009’d
    68 %put &fdos ;
    01JUN2007
    69 %put &ldos ;
    30SEP2009
    70 %put &q ;
    71
    72
    73 libname biplr’/home/jshafi01/projects/adhoc/biplr_dprsn/data’;
    NOTE: Libref BIPLR was successfully assigned as follows:
    Engine: V9
    Physical Name: /home/jshafi01/projects/adhoc/biplr_dprsn/data
    74 libname rosdwp oracle user=»&oracle_user.» pass=»&oracle_pass.» buffsize=32767 path=’rosdwp’;
    NOTE: Libref ROSDWP was successfully assigned as follows:
    Engine: ORACLE
    Physical Name: rosdwp
    75
    76 data work.biplr_up_v1;
    77 attrib mbr_id length=$26;
    78 set biplr.biplr_ubh_med_v1;
    79 run;
    NOTE: There were 0 observations read from the data set BIPLR.BIPLR_UBH_MED_V1.
    NOTE: The data set WORK.BIPLR_UP_V1 has 0 observations and 1 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.01 seconds
    3 The SAS System 11:44 Friday, October 30, 2009
    cpu time 0.00 seconds
    80
    81 proc contents;
    82 run;
    NOTE: PROCEDURE CONTENTS used (Total process time):
    real time 0.03 seconds
    cpu time 0.03 seconds
    83
    84 proc datasets
    85      library = rosdwp nolist;
    86      delete biplr_up_v1;
    87 quit;
    NOTE: Deleting ROSDWP.BIPLR_UP_V1 (memtype=DATA).
    NOTE: PROCEDURE DATASETS used (Total process time):
    real time 3.74 seconds
    cpu time 0.03 seconds
    88
    89 proc datasets
    90      library=work nolist;
    91      copy out = rosdwp move;
    92      select biplr_up_v1 ;
    93 quit;
    NOTE: Moving WORK.BIPLR_UP_V1 to ROSDWP.BIPLR_UP_V1 (memtype=DATA).
    NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables.
    NOTE: There were 0 observations read from the data set WORK.BIPLR_UP_V1.
    NOTE: The data set ROSDWP.BIPLR_UP_V1 has 0 observations and 1 variables.
    NOTE: PROCEDURE DATASETS used (Total process time):
    real time 0.32 seconds
    cpu time 0.04 seconds
    94
    95
    96
    97 *****************************************************************************;
    98
    99 *execute(commit) by rosdwp
    100 ******************************************************************************;
    101
    102
    103 proc SQL noprint ;
    104 connect to oracle as rosdwp (user=»&oracle_user.» password=»&oracle_pass» buffsize=32767 path=’rosdwp’
    104 ! preserve_comments);
    105      execute(alter session set nls_date_format = ‘ddmonyyyy’) by rosdwp;
    106 CREATE table biplr_rx as
    107 SELECT
    108 mrb_id,
    109 pcp_spc,
    110 rx_date,
    4 The SAS System 11:44 Friday, October 30, 2009
    111 brand,
    112 generic,
    113 ahfs_cd,
    114 ahfs_dsc,
    115 lbl,
    116 strngth,
    117 unt,
    118 spc_tx_cls_cd,
    119 spc_tx_cls_dsc,
    120 gcn,
    121 rx_num,
    122 rx_ingrd,
    123 rx_paid,
    124 rx_cnt,
    125 rx_qty,
    126 rx_day
    127 FROM connection to rosdwp
    128 (SELECT
    129 mid.UNIQ_MBR_ID as mrb_id,
    130 pd.PRVDR_SPCLTY_DESC as pcp_spc,
    131 pcf.LAST_SRVC_DT as rx_date,
    132 dd.BRAND_NAME as brand,
    133 dd.GNRC_NAME as generic,
    134 dd.AHFS_THRPTC_CLS_CD as ahfs_cd,
    135 dd.AHFS_THRPTC_CLS_DESC as ahfs_dsc,
    136 dd.LABEL_NAME as lbl,
    137 dd.STRNGTH_NUM as strngth,
    138 dd.STRNGTH_UNIT_DESC as unt,
    139 dd.SPECF_THRPTC_CLS_CD as spc_tx_cls_cd,
    140 dd.SPECF_THRPTC_CLS_DESC as spc_tx_cls_dsc,
    141 dd.GCN_NUM as gcn,
    142 pcf.PRSCRPTN_NUM as rx_num,
    143 SUM(pcf.INGRDNT_AMT) as rx_ingrd,
    144 SUM(pcf.PD_AMT) as rx_paid,
    145 SUM(pcf.UNIT_SRVC_CNT) as rx_cnt,
    146 SUM(pcf.DSPNSD_QTY) as rx_qty,
    147 SUM(pcf.DAY_SUPLY_CNT) as rx_day
    148 FROM
    149 PHRMCY_CLM_FACT pcf,
    150 MBR_ID_DMNSN mid,
    151 DRUG_DMNSN dd,
    152 PRVDR_DMNSN pd,
    153           biplr_up_v1
    154 WHERE
    155 (
    156 (biplr_up_v1.mbr_id = MBR_ID_DMNSN.UNIQ_MBR_ID) And
    157 (PHRMCY_CLM_FACT.FINL_CLM_KEY = PHRMCY_FINL_CLM_DMNSN.FINL_CLM_KEY) AND
    158 (PHRMCY_CLM_FACT.MBR_KEY = MBR_ID_DMNSN.MBR_KEY) And
    159 (PHRMCY_CLM_FACT.BNFT_KEY = MBR_BNFT_DMNSN.BNFT_KEY) And
    160 (PHRMCY_CLM_FACT.DRUG_KEY = DRUG_DMNSN.DRUG_KEY) And
    161 (PHRMCY_FINL_CLM_DMNSN.CLM_ORGN_CD IN (‘M’,’A’)) AND
    162 (PHRMCY_CLM_FACT.LAST_SRVC_DT BETWEEN between &q.&fdos.&q and &q.&ldos.&q)
    163      )
    164 Group By
    165 mid.UNIQ_MBR_ID ,
    166 pd.PRVDR_SPCLTY_DESC ,
    167 pcf.LAST_SRVC_DT ,
    168 dd.BRAND_NAME ,
    5 The SAS System 11:44 Friday, October 30, 2009
    169 dd.GNRC_NAME ,
    170 dd.AHFS_THRPTC_CLS_CD ,
    171 dd.AHFS_THRPTC_CLS_DESC ,
    172 dd.LABEL_NAME ,
    173 dd.STRNGTH_NUM ,
    174 dd.STRNGTH_UNIT_DESC ,
    175 dd.SPECF_THRPTC_CLS_CD ,
    176 dd.SPECF_THRPTC_CLS_DESC ,
    177 dd.GCN_NUM ,
    178 pcf.PRSCRPTN_NUM
    179 );
    ERROR: ORACLE prepare error: ORA-00936: missing expression. SQL statement: SELECT mid.UNIQ_MBR_ID as mrb_id,
    pd.PRVDR_SPCLTY_DESC as pcp_spc, pcf.LAST_SRVC_DT as rx_date, dd.BRAND_NAME as brand, dd.GNRC_NAME as generic,
    dd.AHFS_THRPTC_CLS_CD as ahfs_cd, dd.AHFS_THRPTC_CLS_DESC as ahfs_dsc, dd.LABEL_NAME as lbl, dd.STRNGTH_NUM as
    strngth, dd.STRNGTH_UNIT_DESC as unt, dd.SPECF_THRPTC_CLS_CD as spc_tx_cls_cd, dd.SPECF_THRPTC_CLS_DESC as
    spc_tx_cls_dsc, dd.GCN_NUM as gcn, pcf.PRSCRPTN_NUM as rx_num, SUM(pcf.INGRDNT_AMT) as rx_ingrd, SUM(pcf.PD_AMT)
    as rx_paid, SUM(pcf.UNIT_SRVC_CNT) as rx_cnt, SUM(pcf.DSPNSD_QTY) as rx_qty, SUM(pcf.DAY_SUPLY_CNT) as rx_day
    FROM PHRMCY_CLM_FACT pcf, MBR_ID_DMNSN mid, DRUG_DMNSN dd, PRVDR_DMNSN pd, biplr_up_v1 WHERE (
    (biplr_up_v1.mbr_id = MBR_ID_DMNSN.UNIQ_MBR_ID) And (PHRMCY_CLM_FACT.FINL_CLM_KEY =
    PHRMCY_FINL_CLM_DMNSN.FINL_CLM_KEY) AND (PHRMCY_CLM_FACT.MBR_KEY = MBR_ID_DMNSN.MBR_KEY) And
    (PHRMCY_CLM_FACT.BNFT_KEY = MBR_BNFT_DMNSN.BNFT_KEY) And (PHRMCY_CLM_FACT.DRUG_KEY = DRUG_DMNSN.DRUG_KEY) And
    (PHRMCY_FINL_CLM_DMNSN.CLM_ORGN_CD IN (‘M’,’A’)) AND (PHRMCY_CLM_FACT.LAST_SRVC_DT BETWEEN between ’01JUN2007′
    and ’30SEP2009′) ) Group By mid.UNIQ_MBR_ID , pd.PRVDR_SPCLTY_DESC , pcf.LAST_SRVC_DT , dd.BRAND_NAME ,
    dd.GNRC_NAME , dd.AHFS_THRPTC_CLS_CD , dd.AHFS_THRPTC_CLS_DESC , dd.LABEL_NAME , dd.STRNGTH_NUM ,
    dd.STRNGTH_UNIT_DESC , dd.SPECF_THRPTC_CLS_CD , dd.SPECF_THRPTC_CLS_DESC , dd.GCN_NUM , pcf.PRSCRPTN_NUM.
    NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
    180 execute (drop table biplr_up_v1) by rosdwp;
    NOTE: Statement not executed due to NOEXEC option.
    181 disconnect from rosdwp;
    NOTE: Statement not executed due to NOEXEC option.
    182 quit;
    NOTE: The SAS System stopped processing this step because of errors.
    NOTE: PROCEDURE SQL used (Total process time):
    real time 0.14 seconds
    cpu time 0.03 seconds
    183
    184

    Hello Again ,
    Wish Oracle was a bit more informative. Am using a SAS Institute Product called Enterprise Guide. A «hot fix» was installed to address an issue that the product appears unable to save the latest version of edited code changes (hence » BETWEEN between» remaining even after a prior edit). In any case, with the change, am now receiving this error:
    » ERROR: ORACLE prepare error: ORA-00904: «PHRMCY_CLM_FACT».»LAST_SRVC_DT»: invalid identifier». (Log file appears below)
    -The error remains, regardless of whether one uses «pass through» code to pass the date range to Oracle (which looks ok from the log output below I believe), or if I hard code the date range into the PL SQL query itself.
    -The Prepare error always appears at end of the inner SELECT.
    -The Prepare error remains, with or without the GROUP BY clause.
    Is there anything else here I am missing? Someone suggested a reserve word — but from other ANSI SQL versions, I do not see that is the case. I have consulted SAS Tech Support and SAS List Serve at University of GA. but nothing definitive from these sources. Have requested facility to be able to run Oracle directly, outside this SAS Institute product — in process.
    Any suggestions are greatly appreciated. Thanks to everyone very much.
    Jeff
    14 /********************************************************/
    15 * RX_BIPLR_V3.SAS ;
    16 /********************************************************/
    17
    18 dm ‘log;clear;out;clear’;
    19 options linesize =120;
    20 Option obs=0 NoReplace;
    21
    22 ****************************************************************************************;
    23 *Date       Programmer         Reviewed By     WHAT WAS DONE;
    24 *——      —————     ————    ——————————————;
    25 *2005 D. Boyd Program creation for test population;
    26 *;
    27 *02/06/2006 I. Jones Modified to include total population;
    28 *;
    29 *07/20/2006 I. Jones Identified data elements for exclusion;
    30 * or inclusion for consolidation with ;
    31 * Robin’s report;
    32 *;
    33 *08/18/2006 I Jones Updated the Specific Therapeutic Classes;
    34 * 10-2009 J Shaf — modified to extract actual or potential Bipolar Dx from UBH and Medical Claims;
    35 ****************************************************************************************;
    36
    37
    38
    39 *%let allclmorgn = (‘M’,’A’) ; /* all claims origin code */
    40 %let begdate=’01SEP2009’d;
    41 %let enddate=’30SEP2009’d;
    42 %let q = %str(%’) ;
    43
    44
    45 data null ;
    46 call symput(‘fdos’,put(intnx(‘month’,»&begdate»d,-27,’beginning’), date9.) ) ;
    47 call symput(‘ldos’,put(intnx(‘month’,»&enddate»d,-0,’ending’), date9.) ) ;
    48 run ;
    2 The SAS System 12:46 Monday, November 2, 2009
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    cpu time 0.00 seconds
    49
    50
    51
    52 **************************************************************;
    53 * ??Use the data null step to create a macro variable for the ;
    54 * year and month based on the ldos macro variable in the data ;
    55 * step above?? ;
    56 **************************************************************;
    57
    58
    59 data null ;
    60 if month(«&ldos»d) < 10
    61 then call symput(‘yr_mo’,compress(year(«&ldos»d) || ‘0’ || month(«&ldos»d) ) ) ;
    62 else call symput(‘yr_mo’,compress(year(«&ldos»d) || month(«&ldos»d) ) ) ;
    63 run ;
    NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
    61:39 61:64 62:39 62:57
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    cpu time 0.01 seconds
    64
    65 *%put &biplr_dx;
    66 %put &begdate ;
    ’01SEP2009’d
    67 %put &enddate ;
    ’30SEP2009’d
    68 %put &fdos ;
    01JUN2007
    69 %put &ldos ;
    30SEP2009
    70 %put &q ;
    71
    72
    73 libname biplr’/home/jshafi01/projects/adhoc/biplr_dprsn/data’;
    NOTE: Libref BIPLR was successfully assigned as follows:
    Engine: V9
    Physical Name: /home/jshafi01/projects/adhoc/biplr_dprsn/data
    74 libname rosdwp oracle user=»&oracle_user.» pass=»&oracle_pass.» buffsize=32767 path=’rosdwp’;
    NOTE: Libref ROSDWP was successfully assigned as follows:
    Engine: ORACLE
    Physical Name: rosdwp
    75
    76 data work.biplr_up_v1;
    77 attrib mbr_id length=$26;
    78 set biplr.biplr_ubh_med_v1;
    79 run;
    NOTE: There were 0 observations read from the data set BIPLR.BIPLR_UBH_MED_V1.
    NOTE: The data set WORK.BIPLR_UP_V1 has 0 observations and 1 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    cpu time 0.01 seconds
    80
    81 proc contents;
    82 run;
    NOTE: PROCEDURE CONTENTS used (Total process time):
    real time 0.02 seconds
    cpu time 0.02 seconds
    83
    84 proc datasets
    85      library = rosdwp nolist;
    86      delete biplr_up_v1;
    87 quit;
    NOTE: Deleting ROSDWP.BIPLR_UP_V1 (memtype=DATA).
    NOTE: PROCEDURE DATASETS used (Total process time):
    real time 0.61 seconds
    cpu time 0.01 seconds
    88
    89 proc datasets
    90      library=work nolist;
    91      copy out = rosdwp move;
    92      select biplr_up_v1 ;
    93 quit;
    NOTE: Moving WORK.BIPLR_UP_V1 to ROSDWP.BIPLR_UP_V1 (memtype=DATA).
    NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables.
    NOTE: There were 0 observations read from the data set WORK.BIPLR_UP_V1.
    NOTE: The data set ROSDWP.BIPLR_UP_V1 has 0 observations and 1 variables.
    NOTE: PROCEDURE DATASETS used (Total process time):
    real time 0.15 seconds
    cpu time 0.04 seconds
    94
    95
    96
    97 *****************************************************************************;
    98
    99 *execute(commit) by rosdwp
    100 ******************************************************************************;
    101
    102
    103 proc SQL noprint ;
    104 connect to oracle as rosdwp (user=»&oracle_user.» password=»&oracle_pass» buffsize=32767 path=’rosdwp’
    104 ! preserve_comments);
    105      execute(alter session set nls_date_format = ‘ddmonyyyy’) by rosdwp;
    106 CREATE table biplr_rx as
    107 SELECT
    108 mrb_id,
    109 uniq_mbr_id,
    110 pcp_spc,
    111 rx_date,
    112 brand,
    113 generic,
    114 ahfs_cd,
    115 ahfs_dsc,
    116 lbl,
    117 strngth,
    118 unt,
    119 spc_tx_cls_cd,
    120 spc_tx_cls_dsc,
    121 gcn,
    122 rx_num,
    123 rx_ingrd,
    124 rx_paid,
    125 rx_cnt,
    126 rx_qty,
    127 rx_day
    128 FROM connection to rosdwp
    129 (SELECT
    130 mid.UNIQ_MBR_ID as uniq_mrb_id,
    131 blpr.mrb_id.mbr_id,
    132 pd.PRVDR_SPCLTY_DESC as pcp_spc,
    133 pcf.LAST_SRVC_DT as rx_date,
    134 dd.BRAND_NAME as brand,
    135 dd.GNRC_NAME as generic,
    136 dd.AHFS_THRPTC_CLS_CD as ahfs_cd,
    137 dd.AHFS_THRPTC_CLS_DESC as ahfs_dsc,
    138 dd.LABEL_NAME as lbl,
    139 dd.STRNGTH_NUM as strngth,
    140 dd.STRNGTH_UNIT_DESC as unt,
    141 dd.SPECF_THRPTC_CLS_CD as spc_tx_cls_cd,
    142 dd.SPECF_THRPTC_CLS_DESC as spc_tx_cls_dsc,
    143 dd.GCN_NUM as gcn,
    144 pcf.PRSCRPTN_NUM as rx_num,
    145 SUM(pcf.INGRDNT_AMT) as rx_ingrd,
    146 SUM(pcf.PD_AMT) as rx_paid,
    147 SUM(pcf.UNIT_SRVC_CNT) as rx_cnt,
    148 SUM(pcf.DSPNSD_QTY) as rx_qty,
    149 SUM(pcf.DAY_SUPLY_CNT) as rx_day
    150 FROM
    151 PHRMCY_CLM_FACT pcf,
    152 MBR_ID_DMNSN mid,
    153 DRUG_DMNSN dd,
    154 PRVDR_DMNSN pd,
    155      BIPLR_UP_V1 blpr
    156 WHERE
    157 (BIPLR_UP_V1.mbr_id = MBR_ID_DMNSN.UNIQ_MBR_ID) And
    158 (PHRMCY_CLM_FACT.FINL_CLM_KEY = PHRMCY_FINL_CLM_DMNSN.FINL_CLM_KEY) AND
    159 (PHRMCY_CLM_FACT.MBR_KEY = MBR_ID_DMNSN.MBR_KEY) And
    160 (PHRMCY_CLM_FACT.BNFT_KEY = MBR_BNFT_DMNSN.BNFT_KEY) And
    161 (PHRMCY_CLM_FACT.DRUG_KEY = DRUG_DMNSN.DRUG_KEY) And
    162 (PHRMCY_FINL_CLM_DMNSN.CLM_ORGN_CD IN (‘M’,’A’)) AND
    163 (PHRMCY_CLM_FACT.LAST_SRVC_DT BETWEEN &q.&fdos.&q and &q.&ldos.&q)
    164 );
    ERROR: ORACLE prepare error: ORA-00904: «PHRMCY_CLM_FACT».»LAST_SRVC_DT»: invalid identifier. SQL statement: SELECT
    mid.UNIQ_MBR_ID as uniq_mrb_id, blpr.mrb_id.mbr_id, pd.PRVDR_SPCLTY_DESC as pcp_spc, pcf.LAST_SRVC_DT as
    rx_date, dd.BRAND_NAME as brand, dd.GNRC_NAME as generic, dd.AHFS_THRPTC_CLS_CD as ahfs_cd,
    dd.AHFS_THRPTC_CLS_DESC as ahfs_dsc, dd.LABEL_NAME as lbl, dd.STRNGTH_NUM as strngth, dd.STRNGTH_UNIT_DESC as
    unt, dd.SPECF_THRPTC_CLS_CD as spc_tx_cls_cd, dd.SPECF_THRPTC_CLS_DESC as spc_tx_cls_dsc, dd.GCN_NUM as gcn,
    pcf.PRSCRPTN_NUM as rx_num, SUM(pcf.INGRDNT_AMT) as rx_ingrd, SUM(pcf.PD_AMT) as rx_paid, SUM(pcf.UNIT_SRVC_CNT)
    as rx_cnt, SUM(pcf.DSPNSD_QTY) as rx_qty, SUM(pcf.DAY_SUPLY_CNT) as rx_day FROM PHRMCY_CLM_FACT pcf,
    MBR_ID_DMNSN mid, DRUG_DMNSN dd, PRVDR_DMNSN pd, BIPLR_UP_V1 blpr WHERE (BIPLR_UP_V1.mbr_id =
    MBR_ID_DMNSN.UNIQ_MBR_ID) And (PHRMCY_CLM_FACT.FINL_CLM_KEY = PHRMCY_FINL_CLM_DMNSN.FINL_CLM_KEY) AND
    (PHRMCY_CLM_FACT.MBR_KEY = MBR_ID_DMNSN.MBR_KEY) And (PHRMCY_CLM_FACT.BNFT_KEY = MBR_BNFT_DMNSN.BNFT_KEY) And
    (PHRMCY_CLM_FACT.DRUG_KEY = DRUG_DMNSN.DRUG_KEY) And (PHRMCY_FINL_CLM_DMNSN.CLM_ORGN_CD IN (‘M’,’A’)) AND
    (PHRMCY_CLM_FACT.LAST_SRVC_DT BETWEEN ’01JUN2007′ and ’30SEP2009′).
    NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
    165 execute (drop table biplr_up_v1) by rosdwp;
    NOTE: Statement not executed due to NOEXEC option.
    166 disconnect from rosdwp;
    NOTE: Statement not executed due to NOEXEC option.
    167 quit;
    NOTE: The SAS System stopped processing this step because of errors.
    NOTE: PROCEDURE SQL used (Total process time):
    real time 0.24 seconds
    cpu time 0.02 seconds
    168
    Edited by: user12142482 on Nov 2, 2009 4:02 PM

  • ERROR: ORA-01017: invalid username/password; logon denied

    Hi all
    I need your kind help.
    I have installed Oracle Audit Vault Server  Release 10.2.3.2 in Linux system and collection agent in Windows system. Adding and starting DBAUD collector went fine however  adding REDO collector return back errors when executing avorcldb add_collector command as follow
    [[email protected] ~]$
    [[email protected] ~]$  avorcldb add_collector -srcname orcl -agentname avagent01 -colltype REDO -av Lugaopc:1521:orcl
    collector REDO_Collector for source orcl already exists
    initializing REDO Collector
    ERROR: could not get AV source user connection using jdbc:oracle:oci:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lugaopc)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))
    ERROR: ORA-01017: invalid username/password; logon denied
    [[email protected] ~]$
    Here is the contents of avorcldb.log file
    09-09-13 16:58:44 [INFO ] Processing command add_collector
    09-09-13 16:58:44 [INFO ] Processing arg -srcname = orcl
    09-09-13 16:58:44 [INFO ] Processing arg -agentname = avagent01
    09-09-13 16:58:44 [INFO ] Processing arg -colltype = REDO
    09-09-13 16:58:44 [INFO ] Processing arg -av = Lugaopc:1521:orcl
    09-09-13 16:58:44 [INFO ] Connect info : Lugaopc:1521:orcl
    09-09-13 16:58:45 [INFO ] Got AV admin connection using jdbc:oracle:oci:@AVDB
    09-09-13 16:58:45 [INFO ] Executing SQL as [[email protected]] select s.host||’:’||a1.num_value||’:’||a2.char_value from avsys.av$attrvalue a1, avsys.av$attrvalue a2, avsys.av$source s, avsys.av$attrdef ad1, avsys.av$attrdef ad2 where source_name = :1 and a1.inst_id = s.source_id and a2.inst_id = s.source_id and a1.attr_id = ad1.attr_id and ad1.attr_name = ‘PORT’ and a2.attr_id = ad2.attr_id and ad2.attr_name = ‘DB_SERVICE’
    09-09-13 16:58:45 [INFO ] Using bind value orcl
    09-09-13 16:58:45 [INFO ] Return value = Lugaopc:1521:orcl
    09-09-13 16:58:45 [INFO ] Connect info : Lugaopc:1521:orcl
    09-09-13 16:58:45 [INFO ] Executing SQL as [[email protected]] select to_char(source_id) from avsys.av$source where source_name = :1
    09-09-13 16:58:45 [INFO ] Using bind value orcl
    09-09-13 16:58:45 [INFO ] Return value = 1
    09-09-13 16:58:46 [INFO ] Got source user connection using jdbc:oracle:oci:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lugaopc)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select decode(c.status, 1, ‘active’, 0, ‘dropped’, null) from avsys.av$collector c, avsys.av$source s where source_name = :1 and collector_name = :2 and c.source_id = s.source_id
    09-09-13 16:58:46 [INFO ] Using bind value orcl
    09-09-13 16:58:46 [INFO ] Using bind value REDO_Collector
    09-09-13 16:58:46 [INFO ] Return value = active
    09-09-13 16:58:46 [MESG ] collector REDO_Collector for source orcl already exists
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select decode(c.status, 1, ‘active’, 0, ‘dropped’, null) from avsys.av$collector c, avsys.av$source s where source_name = :1 and collector_name = :2 and c.source_id = s.source_id
    09-09-13 16:58:46 [INFO ] Using bind value orcl
    09-09-13 16:58:46 [INFO ] Using bind value REDO_Collector
    09-09-13 16:58:46 [INFO ] Return value = active
    09-09-13 16:58:46 [MESG ] initializing REDO Collector
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select username from avsys.av$source where source_name = :1
    09-09-13 16:58:46 [INFO ] Using bind value orcl
    09-09-13 16:58:46 [INFO ] Return value = AVSRCUSR1
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] {? = call avsys.dbms_audit_vault.reset_source_user(?)}
    09-09-13 16:58:46 [INFO ] Adding mask for user password
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select table_name from user_tables where upper(table_name) = upper(:1)
    09-09-13 16:58:46 [INFO ] Using bind value STREAMS_HEARTBEAT
    09-09-13 16:58:46 [INFO ] Return value = STREAMS_HEARTBEAT
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] drop table streams_heartbeat
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] create table streams_heartbeat( src_dbname varchar2(4000), job_number number, heartbeat_time timestamp)
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] declare dbs_name varchar2(4000); begin select global_name into dbs_name from global_name; insert into streams_heartbeat values (dbs_name, 0, SYSTIMESTAMP); end;
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] create or replace procedure update_heartbeat IS begin update streams_heartbeat set heartbeat_time=(select systimestamp from dual); commit; end;
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select table_name from user_tables where upper(table_name) = upper(:1)
    09-09-13 16:58:46 [INFO ] Using bind value CAPTURE_RULES
    09-09-13 16:58:46 [INFO ] Return value = CAPTURE_RULES
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] drop table capture_rules
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] create table capture_rules( rule_name  varchar2(50), rule_scope varchar2(6),  rule_type  varchar2(3),  obj_name   varchar2(100))
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select global_name from global_name
    09-09-13 16:58:46 [INFO ] Return value = AVDB.AVSRV
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select db_link from user_db_links where db_link = :1
    09-09-13 16:58:46 [INFO ] Using bind value AVDB.AVSRV
    09-09-13 16:58:46 [INFO ] Return value = AVDB.AVSRV
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] drop database link «AVDB.AVSRV»
    09-09-13 16:58:46 [INFO ] Executing SQL as [[email protected]] select version from v$instance
    09-09-13 16:58:46 [INFO ] Return value = 11.2.0.1.0
    09-09-13 16:58:46 [INFO ] Creating DB link using AVDB.AVSRV,AVSRCUSR1,{avsrcusr_pwd},Lugaopc,1521,orcl
    09-09-13 16:58:46 [INFO ] Connecting as srcuser_ora01 to @(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lugaopc)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))
    09-09-13 16:58:46 [INFO ] Output from SQLPlus
    09-09-13 16:58:46 [INFO ]
    09-09-13 16:58:46 [INFO ] Package created.
    09-09-13 16:58:46 [INFO ]
    09-09-13 16:58:46 [INFO ] No errors.
    09-09-13 16:58:47 [INFO ]
    09-09-13 16:58:47 [INFO ] Package body created.
    09-09-13 16:58:47 [INFO ]
    09-09-13 16:58:47 [INFO ] No errors.
    09-09-13 16:58:47 [INFO ]
    09-09-13 16:58:47 [INFO ] Package created.
    09-09-13 16:58:47 [INFO ]
    09-09-13 16:58:47 [INFO ] No errors.
    09-09-13 16:58:47 [INFO ]
    09-09-13 16:58:47 [INFO ] Package body created.
    09-09-13 16:58:47 [INFO ]
    09-09-13 16:58:47 [INFO ] No errors.
    09-09-13 16:58:47 [INFO ] Executing SQL as [[email protected]] select distinct name from user_errors where name = :1
    09-09-13 16:58:47 [INFO ] Using bind value DBMS_SRC_STREAMS_COLLECTOR
    09-09-13 16:58:47 [INFO ] Return value = null
    09-09-13 16:58:47 [ERROR] could not get AV source user connection using jdbc:oracle:oci:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lugaopc)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))
    09-09-13 16:58:47 [ERROR] ORA-01017: invalid username/password; logon denied
    java.sql.SQLException: ORA-01017: invalid username/password; logon denied
        at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:765)
        at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:414)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
        at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:162)
        at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
        at java.sql.DriverManager.getConnection(DriverManager.java:525)
        at java.sql.DriverManager.getConnection(DriverManager.java:140)
        at oracle.av.avca.jdbc.JdbcConnection.<init>(JdbcConnection.java:87)
        at oracle.av.orcldb.DAO.initConnection(DAO.java:79)
        at oracle.av.orcldb.DAO.<init>(DAO.java:64)
        at oracle.av.orcldb.commands.AddCollector.setupCollector(AddCollector.java:746)
        at oracle.av.orcldb.commands.AddCollector.execute(AddCollector.java:230)
        at oracle.av.orcldb.Command.process(Command.java:89)
        at oracle.av.orcldb.Main.process(Main.java:118)
        at oracle.av.orcldb.Main.main(Main.java:132)
    I have searched the forum to my level best without clear solution
    Regards
    Sadock

    Hi gurus
    I don’t believe if this is missing solution from oracle community. I have decided to installed the collction agent and source database in linux system, so now both auditt vault server and collction agent are running in Linux system (but separately)
    I am wondering, avorcldb add_collector -srcname ORCL -agentname avagent01 -colltype DBAUD and  avorcldb add_collector -srcname ORCL -agentname avagent01 -colltype OSAUD -orclhome /u01/app/oracle/product/11.2.0/dbhome_1 are working fine and  I am able to start these collectors
    The  avorcldb verify -src Lugaosrv:1521:ORCL.LUGAOSRV -colltype ALL command also return good results
    [[email protected] ~]$ avorcldb verify -src Lugaosrv:1521:ORCL.LUGAOSRV -colltype ALL
    Enter Source user name: srcuser_ora01
    Enter Source password:          
    source ORCL.LUGAOSRV verified for OS File Audit Collector collector
    source ORCL.LUGAOSRV verified for Aud$/FGA_LOG$ Audit Collector collector
    source ORCL.LUGAOSRV verified for REDO Log Audit Collector collector
    [[email protected] ~]$
    The problem still I am facing is when attempting to add REDO collector. In fact the collector is added successful and i can see it even on EM console.
    [[email protected] ~]$ avorcldb add_collector -srcname ORCL -agentname avagent01 -colltype REDO -av Lugaosrv:1521:ORCL.LUGAOSRV
    source ORCL verified for REDO Log Audit Collector collector
    Adding collector…
    Collector added successfully.
    remember the following information for use in avctl
    Collector name (collname): REDO_Collector
    initializing REDO Collector
    ERROR: could not get AV source user connection using jdbc:oracle:oci:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lugaosrv)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL.LUGAOSRV)))
    ERROR: ORA-01017: invalid username/password; logon denied
    [[email protected] ~]$
    Any help will be appreciated
    Sadock

  • Trying to produce report but have ERROR ORA-00900: invalid SQL statement

    Hi,
    I am new to Oracle so have been experimenting with a few things to get the hang of it. I have been trying to produce a report, but keep getting the error: ORA-00900: invalid SQL statement.
    This happens at my first line of code where I have COLUMN <column_name> HEADING <Heading_name>
    So I am a bit confused — is there a command that I am supposed to issue that indicates to SQL*Plus that I am trying to create a report?
    Also, if I just delete the COLUMN <column_name> HEADING <Heading_name> rows and just start at BREAK ON <column_name> SKIP 1, it produces the same error.
    I am using Oracle 8.0.6 — does this make a difference?
    Here is my code:
    COLUMN a.p_ctryid HEADING ‘Country’
    COLUMN s.p_animid HEADING ‘Stallion ID’
    COLUMN s.p_uname HEADING ‘Stallion Name’
    COLUMN a.p_animid HEADING ‘Horse ID’
    COLUMN d.p_careertp HEADING ‘Career’
    BREAK ON s.p_animid SKIP 1
    BREAK ON d.p_careertp SKIP 2
    COMPUTE SUM LABEL ‘Total’ OF d.p_careertp ON REPORT
    SELECT DISTINCT a.p_ctryid, s.p_animid, s.p_uname, a.p_animid, d.p_careertp
    FROM p_owby.p_animal a, p_owby.p_animal s, p_owby.p_mating m, p_owby.p_anim_dtl d
    WHERE m.p_mateyr = 2001
    AND a.p_animid = d.p_animid
    AND a.p_animid = m.p_animid
    AND a.p_animid > 0
    AND s.p_animid = a.p_sire
    AND a.p_ctryid IN(‘GB’,’IRE’)
    GROUP BY a.p_ctryid, s.p_animid, s.p_uname, d.p_careertp, a.p_animid
    ORDER BY a.p_ctryid, s.p_animid, d.p_careertp
    Any help would be greatly appreciated!
    Thanks in advance!

    You are trying to do COMPUTE SUM … ON REPORT but there is no BREAK ON REPORT specified. The computed sum will not be shown unless you also break on report. see below demonstration. first select has no sum even though we have specified COMPUTE. The second select shows the sum since now we have done break on report.
    SQL> compute sum of sal on report
    SQL> select * from scott.emp order by empno ;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10
    14 rows selected.
    SQL> break on report
    SQL> select * from scott.emp order by empno ;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10
    sum                                                         29025
    14 rows selected.
    SQL>

  • Annals of Oracle’s Improbable Errors

    Welcome to Flavio Casetta’s official Oracle database application development related blog. No Mysql supporters were hurt in the making of this blog.

    Thursday, March 28, 2013

    invalid LOB locator specified: ORA-22275

    Just a simple reminder (I tend to forget things over the centuries) when using procedure DBMS_LOB.CONVERTTOCLOB with persistent lob locators:

    1. don’t forget to include the FOR UPDATE clause in the SELECT statement fetching the lob locators.
    2. don’t forget to initialize the destination lob (in this case the clob column DOC ) with EMPTY_CLOB() .

    otherwise ORA-22275 may occur (see also another cause of this error).

    In the PL/SQL fragment above, column DOC was null, which is a different value from EMPTY_CLOB() .
    As this column is always null when the record is created, I modified the default value of the column as follows:

    This avoids the annoyance of having to update the row and set DOC to EMPTY_CLOB() before calling DBMS_LOB.CONVERTTOCLOB.

    See message translations for ORA-22275 and search additional resources.

    1 comment:

    Hi,
    I used your solution.
    but it did not work :(.


    Error report:
    ORA-22275: invalid LOB locator specified
    ORA-06512: at line 29
    22275. 00000 — «invalid LOB locator specified»
    *Cause: There are several causes
    initialized; (2) the locator is for a BFILE and the routine
    expects a BLOB/CLOB/NCLOB locator; (3) the locator is for a
    BLOB/CLOB/NCLOB and the routine expects a BFILE locator;
    (4) trying to update the LOB in a trigger body — LOBs in
    trigger bodies are read only; (5) the locator is for a
    BFILE/BLOB and the routine expects a CLOB/NCLOB locator;
    (6) the locator is for a CLOB/NCLOB and the routine expects
    a BFILE/BLOB locator;
    *Action: For (1), initialize the LOB locator by selecting into the locator
    variable or by setting the LOB locator to empty. For (2),(3),
    (5) and (6)pass the correct type of locator into the routine.
    For (4), remove the trigger body code that updates the LOB value.

    I presented the problem in other forums,
    but did not have an answer I answer.

    Источник

    ORA-22275 — invalid LOB locator specified

    I have a procedure which reads an xml file and inserts and updates tables accordingly. It works fine with most files, but with this one, it gives me an ORA-22275 error. I have tried many things, and I don’t know why. Here is the file, simplified:

    PORT MAIN ENGINE

    Here’s PART of the procedure:

    PROCEDURE form_load_xml(p_filename IN VARCHAR2) IS

    l_bfile BFILE := BFILENAME(‘XML_DIR’, p_filename);

    rec_total := 0; rec_processed := 0;

    DBMS_LOB.createtemporary (l_clob, TRUE);

    DBMS_LOB.loadfromfile(l_clob, l_bfile, DBMS_LOB.getlength(l_bfile));

    — Create a parser.

    — Parse the document and create a new DOM document.

    — Free resources associated with the CLOB and Parser now they are no longer needed.

    — Get a list of all the EMP nodes in the document using the XPATH syntax.

    — Loop through the list and create a new record in the table

    FOR cur_xml IN 0 .. dbms_xmldom.getLength(l_nl) — 1

    l_n := dbms_xmldom.item(l_nl, cur_xml);

    — Free any resources associated with the document now it is no longer needed.

    :NAVY_TEMP.f_comment := :NAVY_TEMP.f_comment || to_char(f_custno)||’-‘||to_char(f_plantno)||

    ‘, records total — ‘||to_char(rec_total)||’, processed — ‘ || to_char(rec_processed);

    :REC_OF := ‘Record ‘ ||:System.Cursor_Record || ‘ of ‘ || :total_r;

    WHEN OTHERS THEN

    The name of this file is: ER_FAAS_Seagull(Ver15)_20161122.xml

    I know it is hard to understand this, and it is hard to test. But maybe from your experience you might have at least some ideas as to what could be wrong?

    Error: ORA-22275 — Invalid LOB locator specified

    Best Answer

    First things first, remove the exception handler and recreate the error. Find out which line it happens on. Post that back here.

    Secondly, put some safety measures in to prevent the possibility of deallocating multiple times, see if that fixes it. Here’s a quick and dirty approach below, changes in bold, note, I haven’t checked if it would work.

    PROCEDURE form_load_xml(p_filename IN VARCHAR2) IS

    l_bfile BFILE := BFILENAME(‘XML_DIR’, p_filename);

    rec_total := 0; rec_processed := 0;

    DBMS_LOB.createtemporary (l_clob, TRUE);

    DBMS_LOB.loadfromfile(l_clob, l_bfile, DBMS_LOB.getlength(l_bfile));

    — Create a parser.

    — Parse the document and create a new DOM document.

    — Free resources associated with the CLOB and Parser now they are no longer needed.

    l_clob := null;

    l_parser := null;

    — Get a list of all the EMP nodes in the document using the XPATH syntax.

    — Loop through the list and create a new record in the table

    FOR cur_xml IN 0 .. dbms_xmldom.getLength(l_nl) — 1

    l_n := dbms_xmldom.item(l_nl, cur_xml);

    — Free any resources associated with the document now it is no longer needed.

    l_doc := null;

    :NAVY_TEMP.f_comment := :NAVY_TEMP.f_comment || to_char(f_custno)||’-‘||to_char(f_plantno)||

    ‘, records total — ‘||to_char(rec_total)||’, processed — ‘ || to_char(rec_processed);

    :REC_OF := ‘Record ‘ ||:System.Cursor_Record || ‘ of ‘ || :total_r;

    WHEN OTHERS THEN

    if l_clob is not null then

    end if;

    if l_parser is not null then

    end if;

    if l_doc is not null then

    end if;

    raise;

    Answers

    22275, 00000, «invalid LOB locator specified»

    // *Cause: There are several causes: (1) the LOB locator was never

    // initialized; (2) the locator is for a BFILE and the routine

    // expects a BLOB/CLOB/NCLOB locator; (3) the locator is for a

    // BLOB/CLOB/NCLOB and the routine expects a BFILE locator;

    // (4) trying to update the LOB in a trigger body — LOBs in

    // trigger bodies are read only; (5) the locator is for a

    // BFILE/BLOB and the routine expects a CLOB/NCLOB locator;

    // (6) the locator is for a CLOB/NCLOB and the routine expects

    // a BFILE/BLOB locator;

    // *Action: For (1), initialize the LOB locator by selecting into the locator

    // variable or by setting the LOB locator to empty. For (2),(3),

    // (5) and (6)pass the correct type of locator into the routine.

    // For (4), remove the trigger body code that updates the LOB value.

    At a minimum the WHEN OTHERS should contain

    Why are you using dbms_xmlparser? Your approach seems very convoluted and inefficient. Why not load the XML into an XMLType directly using XMLType.

    Then use XMLTable, XMLQuery etc. to load the extracted data into your destination tables. Your XPath would govern how much of the DOM needs loading internally.

    Your WHEN OTHERS is problematic, for several reasons

    1. It suppresses the actual error call stack (giving you the error line number)
    2. You should always re-raise the error at the end of when OTHERS cleanup code.
    3. It is attempting to free resources that may not have been allocated or may have already been deallocated, for example, what if the error occurred after these lines below. you are still attempting to free a lob and a parser that may have already been freed! You should probably check the l_clob is open not null before using DBMS_LOB.ISOPEN, similarly with the parser. It wouldn’t surprise me if this is the source of the problem.

    1. there is a form which is used to update client specifications in different tables through reading a XML file received from the client:

    2. the client sends one or many XML files to be processed once or twice a week

    4. the procedure mentioned previously is invoked by the UPLOAD button.

    3. all files are processed successfully, except for the one I mention in the original post.

    4. when the UPLOAD button is pressed, this error appears:

    again, ALL OTHER FILES DO NOT RAISE THIS ERROR.

    I checked the file itself, IT IS STRUCTURALLY IDENTICAL to the successful ones.

    I will try to place my ‘freeing this because it is no longer needed’ code at the end, but why are the other files working just fine.

    Источник

    PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275

    I want to copy blob data from coloum of type blob to procedure out parameter of blob type .
    For that i m using
    dbms_lob.copy(document, bdoc, dbms_lob.getlength(bdoc);

    Procedure is compiled successfully but during execution it gives below error
    The Error number is ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275

    Mention below is my sample procedure :

    CREATE OR REPLACE PROCEDURE APPS.XXHDFC_ATTACH_CAPEX_TEST_PROC
    (
    document_id IN VARCHAR2
    —,display_type IN VARCHAR2
    ,document IN OUT bLOB
    ,P_media_id out number
    ,document_type IN OUT VARCHAR2
    ) IS
    lob_id NUMBER;
    l_media_id number;
    bdoc bLOB;
    content_type VARCHAR2(100);
    filename VARCHAR2(300);
    l_layout_id boolean;
    l_request_id number;
    l_rowid rowid;
    l_attached_document_id number;
    l_document_id number;
    l_document_id1 number;
    — l_media_id number;
    l_category_id number := 1; — OE_ORDER_HEADERS
    l_pk1_value fnd_attached_documents.pk1_value%TYPE ;
    l_description fnd_documents_tl.description%TYPE := ‘CAPEX HISTORY OUTPUT’;
    l_filename fnd_documents_tl.file_name%TYPE ;
    k_filename fnd_documents_tl.file_name%TYPE := ‘HDFCE_ERGO_CAPEX_HISTORY_OUTPUT.PDF’ ;
    l_seq_num number;
    l_blob_data blob;
    v_blob blob ;
    l_blob blob;
    l_bfile bfile;
    l_byte number;
    v_finished BOOLEAN;
    v_phase VARCHAR2(240);
    v_status VARCHAR2(240);
    v_request_phase VARCHAR2(240);
    v_request_status VARCHAR2(240);
    v_message VARCHAR2(240);
    l_document_type varchar2(25);
    l_doc_subtype varchar2(25);
    L_ITEM_TYPE WF_ITEMS.ITEM_TYPE%TYPE;
    L_ITEM_KEY WF_ITEMS.ITEM_KEY%TYPE;
    l_release_no number;
    P_HEADER_ID number;
    v_in Pls_Integer := 1;
    v_out Pls_Integer := 1;
    v_lang number := dbms_lob.default_lang_ctx;
    v_warning Pls_Integer := 0;
    l_FILE_DAta blob ;

    fnd_global.apps_initialize(1210,50756,7000);
    l_item_type := substr(document_id, 1, instr(document_id, ‘:’) — 1);
    l_item_key := substr(document_id, instr(document_id, ‘:’) + 1,length(document_id) — 2);

    — l_document_type := wf_engine.GetItemAttrText (itemtype => l_item_type,
    — itemkey => l_item_key,
    — aname => ‘DOCUMENT_TYPE’);

    — l_doc_subtype := wf_engine.GetItemAttrText (itemtype => l_item_type,
    — itemkey => l_item_key,
    — aname => ‘DOCUMENT_SUBTYPE’);

    l_document_id := wf_engine.GetItemAttrNumber
    (itemtype => l_item_type,
    itemkey => l_item_key,
    aname => ‘DOCUMENT_ID’);

    — Obtain the BLOB version of the document

    l_layout_id := fnd_request.add_layout (template_appl_name => ‘PO’,
    template_code => ‘XXHDFCCAPEXAPPRHIS’,
    template_language => ‘en’,
    template_territory => ‘US’,
    output_format => ‘PDF’
    );

    l_request_id := fnd_request.submit_request(‘PO’,
    ‘XXHDFCCAPEXAPPRHIS’,
    null,
    null,
    false,
    lob_id, —P_report_type
    null , —P_agend_id
    null, —P_po_num_from
    null , —P_po_num_to
    null , —P_relaese_num_from
    null , —P_release_num_to
    null , —P_date_from
    null , —P_date_to
    null , —P_approved_flag
    null, —P_test_flag
    null , —P_print_releases
    null , —P_sortby
    null , —P_user_id
    null , —P_fax_enable
    null , —P_fax_number
    null , —P_BLANKET_LINES
    null, —View_or_Communicate,
    null, —P_WITHTERMS
    null, —P_storeFlag
    null, —P_PRINT_FLAG
    null, —P_DOCUMENT_ID
    null, —P_REVISION_NUM
    null, —P_AUTHORIZATION_STATUS
    null, —P_DOCUMENT_TYPE
    null,—P_max_zip_size,

    null, — P_PO_TEMPLATE_CODE
    null, — P_CONTRACT_TEMPLATE_CODE
    null,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL);

    v_finished := fnd_concurrent.wait_for_request
    (
    request_id => l_request_id,
    interval => 5,
    max_wait => 120,
    phase => v_phase,
    status => v_status,
    dev_phase => v_request_phase,
    dev_status => v_request_status,
    message => v_message
    );

    select FND_DOCUMENTS_S.nextval
    into l_document_id1
    from dual;

    select FND_ATTACHED_DOCUMENTS_S.nextval
    into l_attached_document_id
    from dual;

    select nvl(max(seq_num),0) + 10
    into l_seq_num
    from fnd_attached_documents
    where pk1_value = l_pk1_value
    and entity_name = ‘REQ_HEADERS’;

    select substr(file_name,instr(file_name ,’/’,-1,1)+1)
    into l_filename
    from FND_CONC_REQ_OUTPUTS where CONCURRENT_REQUEST_ID =l_request_id;

    fnd_documents_pkg.insert_row
    ( X_ROWID => l_rowid
    , X_DOCUMENT_ID => l_document_id1
    , X_CREATION_DATE => sysdate
    , X_CREATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_DATE => sysdate
    , X_LAST_UPDATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_LOGIN => fnd_profile.value(‘LOGIN_ID’)
    , X_DATATYPE_ID => 6 — FILE
    , X_CATEGORY_ID => l_category_id
    , X_SECURITY_TYPE => 4
    , X_PUBLISH_FLAG => ‘Y’
    , X_USAGE_TYPE => ‘O’
    , X_LANGUAGE => ‘US’
    , X_DESCRIPTION => l_description
    , X_FILE_NAME => l_filename
    , X_MEDIA_ID => l_media_id
    );

    commit;
    INSERT INTO fnd_lobs (file_id
    ,file_name
    ,file_content_type
    ,upload_date
    ,expiration_date
    ,program_name
    ,program_tag
    ,file_data
    ,language
    ,oracle_charset
    ,file_format
    )
    values
    (
    l_media_id,
    k_filename,
    ‘application/pdf’,
    sysdate,
    null,
    null,
    null,
    empty_blob (), —l_blob_data,
    null,
    null,
    ‘binary’
    ) returning file_data into l_blob;

    DBMS_LOB.CREATETEMPORARY(l_blob,true);
    l_bfile := bfilename (‘EXAMPLEDIR3’, l_filename);
    l_byte := dbms_lob.getlength(l_bfile);
    dbms_output.put_line (‘size is ‘||l_byte);
    dbms_lob.fileopen (l_bfile);
    dbms_lob.loadfromfile (l_blob, l_bfile, l_byte);
    dbms_lob.fileclose(l_bfile);
    dbms_output.put_line (‘document id is ‘||l_document_id1 );

    update fnd_lobs
    set file_data=l_blob
    where file_id=l_media_id;

    fnd_documents_pkg.insert_tl_row
    ( X_DOCUMENT_ID => l_document_id1
    , X_CREATION_DATE => sysdate
    , X_CREATED_BY => 1175
    , X_LAST_UPDATE_DATE => sysdate
    , X_LAST_UPDATED_BY => 1175
    , X_LAST_UPDATE_LOGIN =>1175
    , X_LANGUAGE => ‘US’
    , X_DESCRIPTION => l_description
    );
    commit;

    fnd_attached_documents_pkg.insert_row
    ( X_ROWID => l_rowid
    , X_ATTACHED_DOCUMENT_ID => l_attached_document_id
    , X_DOCUMENT_ID => l_document_id1
    , X_CREATION_DATE => sysdate
    , X_CREATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_DATE => sysdate
    , X_LAST_UPDATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_LOGIN => fnd_profile.value(‘LOGIN_ID’)
    , X_SEQ_NUM => l_seq_num
    , X_ENTITY_NAME => ‘PO_HEADERS’
    , X_COLUMN1 => null
    , X_PK1_VALUE => l_pk1_value
    , X_PK2_VALUE => null
    , X_PK3_VALUE => null
    , X_PK4_VALUE => null
    , X_PK5_VALUE => null
    , X_AUTOMATICALLY_ADDED_FLAG => ‘N’
    , X_DATATYPE_ID => 6
    , X_CATEGORY_ID => l_category_id
    , X_SECURITY_TYPE => 4
    , X_PUBLISH_FLAG => ‘Y’
    , X_LANGUAGE => ‘US’
    , X_DESCRIPTION => l_description
    , X_FILE_NAME => l_filename
    , X_MEDIA_ID => l_media_id
    );

    DBMS_OUTPUT.PUT_LINE (‘MEDIA ID CREATED IS ‘||L_MEDIA_ID);

    /* SELECT distinct media_id into l_media_id
    FROM FND_ATTACHED_DOCS_FORM_VL
    where pk1_value = lob_id
    and USER_ENTITY_PROMPT = ‘PO Header’
    and category_id =1000504;
    */
    SELECT file_name
    ,file_content_type
    ,file_data
    INTO filename
    ,content_type
    ,bdoc
    FROM fnd_lobs
    WHERE file_id = l_media_id;
    document_type := content_type || ‘;name=’ || filename;

    —DBMS_LOB.convertToBlob(bdoc, bdoc, DBMS_LOB.getlength(bdoc), v_in, v_out,DBMS_LOB.default_csid,
    — v_lang, v_warning);

    dbms_output.put_line( ‘The Length is ‘||dbms_lob.getlength(bdoc)) ;

    dbms_lob.copy(document, bdoc, dbms_lob.getlength(bdoc);

    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line( ‘The Error number is ‘||Sqlerrm) ;
    dbms_output.put_line( ‘The Error is ‘||Sqlerrm) ;
    — null;
    END ;

    Answers

    Code does not abuse uppercase — which is nice.

    Unfortunately, it goes pretty much downhill after that. Lots wrong.

    The most fundamental principle of writing software is modularise. A module is designed to do one thing, and only thing only. And do it well.

    Why this principle? Easy to read and understand it if it does only one thing. Easy to test. East to re-use again and again. Easy to modify. Easy to tune. Easy to port. Etc. Etc.

    You have a single procedure that tries to do lots of different things. One of the clear signs of a flawed design is lots and lots of private variables in a module. You have about 40 variables. Which means the code is going to try at least 40 different things as it needs 40 variables to assign, evaluate, keep track of, and so on.

    The code also does not make sense. Why this:

    The variable l_document_id is already a number. Why convert it to a number?

    Why keep 3 copies of that variable value in 3 different variables? What for? Besides making it more complex as more variables means more stuff to keep track of.. and which of the 3 duplicate variables should be used where and when?

    I stopped counting after 40 parameters. THIS IS WRONG. A parameter signature of that size does not make sense.

    Another fundamental software engineer principle. Structured data — and not just structured programming.

    Define a record type (or SQL user type) that contains related data fields in single structure that can be passed between modules.

    The following is not performant. Why 2 context switches to the SQL engine?
    >

    select FND_DOCUMENTS_S.nextval
    into l_document_id1
    from dual;

    select FND_ATTACHED_DOCUMENTS_S.nextval
    into l_attached_document_id
    from dual;

    Thus can be done using a single context switch and a single SQL statement:
    select FND_DOCUMENTS_S.nextval, FND_ATTACHED_DOCUMENTS_S.nextval into l_document_id1, l_attached_document_id from dual;

    Also, what is the difference between variables l_document_id and l_document_id1. Variable names need to be meaningful. How is the poor sod who is going to maintain this mess, going to know whether to use l_document_id or l_document_id1, when updating or modifying the code?

    Then there is a number of commits that happen. If there is an error, how does the caller know what this module managed to do and commit? This module will result in inconsistent behaviour as it may do all the commits with the 1st call, run into errors with the 2nd and 3rd call, doing 2 commits and 4 commits respectively.

    Another fundamental software engineering principle violated. The caller has no idea WHAT this module actually did and commit. It does not have consistent and predictable behaviour.

    Then there’s the shoddy exception handler that is also totally wrong.

    Writing good code is actually easy. Understand the fundamentals. Stick to the fundamentals. Which is why the sample code posted is a complete software engineering failure. It violates fundamentals. This is not how software should be designed or written.

    After removing an exception i m getting error at below statments

    dbms_lob.copy(document, bdoc, dbms_lob.getlength(bdoc);

    both documnet amd bdoc variable are blob type .

    revised code is mentioned below ;

    CREATE OR REPLACE PROCEDURE APPS.XXHDFC_ATTACH_CAPEX_PROCEDURE
    (
    document_id IN VARCHAR2
    ,display_type IN VARCHAR2
    ,document IN OUT BLOB
    ,document_type IN OUT VARCHAR2
    ) IS
    —lob_id NUMBER;
    l_media_id number;
    bdoc BLOB;
    content_type VARCHAR2(100);
    filename VARCHAR2(300);
    l_layout_id boolean;
    l_request_id number;
    l_rowid rowid;
    l_attached_document_id number;
    l_document_id number;
    l_document_id1 number;
    — l_media_id number;
    l_category_id number := 1; — OE_ORDER_HEADERS
    — l_pk1_value fnd_attached_documents.pk1_value%TYPE ;
    l_description fnd_documents_tl.description%TYPE := ‘CAPEX HISTORY OUTPUT’;
    l_filename fnd_documents_tl.file_name%TYPE ;
    k_filename fnd_documents_tl.file_name%TYPE := ‘HDFCE_ERGO_CAPEX_HISTORY_OUTPUT.PDF’ ;
    l_seq_num number;
    l_blob_data blob;
    l_blob blob;
    l_bfile bfile;
    l_byte number;
    v_finished BOOLEAN;
    v_phase VARCHAR2(240);
    v_status VARCHAR2(240);
    v_request_phase VARCHAR2(240);
    v_request_status VARCHAR2(240);
    v_message VARCHAR2(240);
    l_document_type varchar2(25);
    l_doc_subtype varchar2(25);
    L_ITEM_TYPE WF_ITEMS.ITEM_TYPE%TYPE;
    L_ITEM_KEY WF_ITEMS.ITEM_KEY%TYPE;
    l_release_no number;
    P_HEADER_ID number;
    BEGIN

    fnd_global.apps_initialize(1175,50644,7000);
    l_item_type := substr(document_id, 1, instr(document_id, ‘:’) — 1);
    l_item_key := substr(document_id, instr(document_id, ‘:’) + 1,length(document_id) — 2);

    l_document_type := wf_engine.GetItemAttrText (itemtype => l_item_type,
    itemkey => l_item_key,
    aname => ‘DOCUMENT_TYPE’);

    l_doc_subtype := wf_engine.GetItemAttrText (itemtype => l_item_type,
    itemkey => l_item_key,
    aname => ‘DOCUMENT_SUBTYPE’);
    l_document_id := wf_engine.GetItemAttrNumber
    (itemtype => l_item_type,
    itemkey => l_item_key,
    aname => ‘DOCUMENT_ID’);

    — l_pk1_value := l_document_id; — Obtain the BLOB version of the document

    l_layout_id := fnd_request.add_layout (template_appl_name => ‘PO’,
    template_code => ‘XXHDFCCAPEXAPPRHIS’,
    template_language => ‘en’,
    template_territory => ‘US’,
    output_format => ‘PDF’
    );

    l_request_id := fnd_request.submit_request(‘PO’,
    ‘XXHDFCCAPEXAPPRHIS’,
    null,
    null,
    false,
    l_document_id , —P_report_type
    null , —P_agend_id
    null, —P_po_num_from
    null , —P_po_num_to
    null , —P_relaese_num_from
    null , —P_release_num_to
    null , —P_date_from
    null , —P_date_to
    null , —P_approved_flag
    null, —P_test_flag
    null , —P_print_releases
    null , —P_sortby
    null , —P_user_id
    null , —P_fax_enable
    null , —P_fax_number
    null , —P_BLANKET_LINES
    null, —View_or_Communicate,
    null, —P_WITHTERMS
    null, —P_storeFlag
    null, —P_PRINT_FLAG
    null, —P_DOCUMENT_ID
    null, —P_REVISION_NUM
    null, —P_AUTHORIZATION_STATUS
    null, —P_DOCUMENT_TYPE
    null,—P_max_zip_size,

    null, — P_PO_TEMPLATE_CODE
    null, — P_CONTRACT_TEMPLATE_CODE
    null,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
    NULL, NULL);

    v_finished := fnd_concurrent.wait_for_request
    (
    request_id => l_request_id,
    interval => 5,
    max_wait => 120,
    phase => v_phase,
    status => v_status,
    dev_phase => v_request_phase,
    dev_status => v_request_status,
    message => v_message
    );

    select FND_DOCUMENTS_S.nextval
    into l_document_id1
    from dual;

    select FND_ATTACHED_DOCUMENTS_S.nextval
    into l_attached_document_id
    from dual;

    select nvl(max(seq_num),0) + 10
    into l_seq_num
    from fnd_attached_documents
    where pk1_value = l_document_id
    and entity_name = ‘REQ_HEADERS’;

    select substr(file_name,instr(file_name ,’/’,-1,1)+1)
    into l_filename
    from FND_CONC_REQ_OUTPUTS where CONCURRENT_REQUEST_ID =l_request_id;

    fnd_documents_pkg.insert_row
    ( X_ROWID => l_rowid
    , X_DOCUMENT_ID => l_document_id1
    , X_CREATION_DATE => sysdate
    , X_CREATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_DATE => sysdate
    , X_LAST_UPDATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_LOGIN => fnd_profile.value(‘LOGIN_ID’)
    , X_DATATYPE_ID => 6 — FILE
    , X_CATEGORY_ID => l_category_id
    , X_SECURITY_TYPE => 4
    , X_PUBLISH_FLAG => ‘Y’
    , X_USAGE_TYPE => ‘O’
    , X_LANGUAGE => ‘US’
    , X_DESCRIPTION => l_description
    , X_FILE_NAME => l_filename
    , X_MEDIA_ID => l_media_id
    );

    commit;
    INSERT INTO fnd_lobs (file_id
    ,file_name
    ,file_content_type
    ,upload_date
    ,expiration_date
    ,program_name
    ,program_tag
    ,file_data
    ,language
    ,oracle_charset
    ,file_format
    )
    values
    (
    l_media_id,
    k_filename,
    ‘application/pdf’,
    sysdate,
    null,
    null,
    null,
    empty_blob (), —l_blob_data,
    null,
    null,
    ‘binary’
    ) returning file_data into l_blob;

    DBMS_LOB.CREATETEMPORARY(l_blob,true);
    l_bfile := bfilename (‘EXAMPLEDIR3’, l_filename);
    l_byte := dbms_lob.getlength(l_bfile);
    dbms_output.put_line (‘size is ‘||l_byte);
    dbms_lob.fileopen (l_bfile);
    dbms_lob.loadfromfile (l_blob, l_bfile, l_byte);
    dbms_lob.fileclose(l_bfile);
    dbms_output.put_line (‘document id is ‘||l_document_id1 );

    update fnd_lobs
    set file_data=l_blob
    where file_id=l_media_id;

    fnd_documents_pkg.insert_tl_row
    ( X_DOCUMENT_ID => l_document_id1
    , X_CREATION_DATE => sysdate
    , X_CREATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_DATE => sysdate
    , X_LAST_UPDATED_BY => fnd_profile.value(‘USER_ID’)
    , X_LAST_UPDATE_LOGIN =>fnd_profile.value(‘USER_ID’)
    , X_LANGUAGE => ‘US’
    , X_DESCRIPTION => l_description
    );
    commit;

    DBMS_OUTPUT.PUT_LINE (‘MEDIA ID CREATED IS ‘||L_MEDIA_ID);

    SELECT file_name
    ,file_content_type
    ,file_data
    INTO filename
    ,content_type
    ,bdoc
    FROM fnd_lobs
    WHERE file_id = l_media_id;
    document_type := content_type || ‘;name=’ || filename;

    Источник

    Понравилась статья? Поделить с друзьями:

    Читайте также:

  • Number of vehicle models 0 как исправить
  • Number of error information log entries что это
  • Number of device paths has reduced error code 1630
  • Number error oracle
  • Num ошибка при синтаксическом анализе пакета

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии