Why DBMS_LOB.CONVERTTOBLOB gives me exception?

Hi, guys:
I have a task to implement a download link in apex to download RTF file. I have finished the APEX part, however, I got the problem in the PL/SQl part. Here is my code:
      procedure downloadTest is
                strLetter clob;
                strLetter_len number;
                v_mime  varchar2(48) := 'application/msword';
                v_blob      BLOB;
                v_blob_offset integer;
                v_clob_offset integer;
                v_blob_csid integer:=DBMS_LOB.DEFAULT_CSID;
                v_lang_context integer:=DBMS_LOB.DEFAULT_LANG_CTX;
                v_warning integer;
                l_server sor_email_config.server%type;
                l_sender sor_email_config.sender%type;
                error_message varchar2(500);
      begin
              strLetter:='Test if this file downloadable!';
              --strLetter_len:=DBMS_LOB.GETLENGTH(strLetter);
              strLetter_len:=DBMS_LOB.LOBMAXSIZE;
              v_blob_offset:=1;
              v_clob_offset:=1;
              v_blob:=null;
              DBMS_LOB.CONVERTTOBLOB(v_blob, strLetter, strLetter_len, v_blob_offset, v_clob_offset, v_blob_csid, v_lang_context, v_warning);
              OWA_UTIL.mime_header (NVL (v_mime, 'application/pdf'), FALSE);
               HTP.p ('Content-length: ' || strLetter_len);
               OWA_UTIL.http_header_close;
               WPG_DOCLOAD.download_file (v_blob);
      exception
          WHEN OTHERS THEN
                  error_message:=substr(SQLERRM, 1, 400);
                  raise_application_error(SOR_ERROR_CONSTANTS_PKG.errnum_GENERAL, 'SOR_COMPLIANCE_ADMIN.downloadTest when generating document '||SOR_ERROR_CONSTANTS_PKG.errmsg_GENERAL||error_message);
      end downloadTest;however, I got exception as follows:
ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275 for Execute PL/SQL Code.
I know the problem occurs during DBMS_LOB.CONVERTTOBLOB. Could anyone give me a hint about this problem?
Thanks a lot!
Sam
Edited by: lxiscas on May 15, 2013 10:09 AM

Thank you for all help you guys provided! I finally made it. It looks APEX 4.1/11GR2 conflicts with wpg_docload.download_file, I have to raise APEX internal exception by calling apex_application.stop_apex_engine, and call the download process in a application process. check Blob download via wpg_docload is not working
for anyone's convenience:
      procedure downloadTest is
                strLetter clob;
                strLetter_len number;
                v_mime  varchar2(48) := 'application/msword';
                --v_mime  varchar2(48);
                v_blob      BLOB;
                v_file_name varchar2(100);
                v_length number;
                v_blob_offset integer;
                v_clob_offset integer;
                v_blob_csid integer:=DBMS_LOB.DEFAULT_CSID;
                v_lang_context integer:=DBMS_LOB.DEFAULT_LANG_CTX;
                v_warning integer;
                l_server sor_email_config.server%type;
                l_sender sor_email_config.sender%type;
                error_message varchar2(500);
      begin
              strLetter:='Test if this file downloadable!';
              --strLetter_len:=DBMS_LOB.GETLENGTH(strLetter);
              strLetter_len:=DBMS_LOB.LOBMAXSIZE;
              v_blob_offset:=1;
              v_clob_offset:=1;
              DBMS_LOB.CREATETEMPORARY(v_blob, true);
              DBMS_LOB.CONVERTTOBLOB(v_blob, strLetter, strLetter_len, v_blob_offset, v_clob_offset, v_blob_csid, v_lang_context, v_warning);
              OWA_UTIL.mime_header (NVL (v_mime, 'application/pdf'), FALSE);
               HTP.p ('Content-length: ' || strLetter_len);
               htp.p( 'Content-Disposition: filename="test"' );
               OWA_UTIL.http_header_close;
               -- download the BLOB
                wpg_docload.download_file( v_blob );
                apex_application.stop_apex_engine;
      exception
          WHEN OTHERS THEN
                  /*error_message:=substr(SQLERRM, 1, 400);
                  raise_application_error(SOR_ERROR_CONSTANTS_PKG.errnum_GENERAL, 'SOR_COMPLIANCE_ADMIN.downloadTest when generating document '||SOR_ERROR_CONSTANTS_PKG.errmsg_GENERAL||error_message);*/
                  HTP.htmlopen;
                  HTP.headopen;
                  HTP.title('File Downloaded');
                  HTP.headclose;
                  HTP.bodyopen;
                  HTP.header(1, 'Download Status');
                  HTP.print(SQLERRM);
                  HTP.bodyclose;
                  HTP.htmlclose;
      end downloadTest;Thank you again for your help!
Sam
Edited by: lxiscas on May 17, 2013 6:52 AM

Similar Messages

  • If image file not exist in image path crystal report not open and give me exception error problem

    Hi guys my code below show pictures for all employees
    code is working but i have proplem
    if image not exist in path
    crystal report not open and give me exception error image file not exist in path
    although the employee no found in database but if image not exist in path when loop crystal report will not open
    how to ignore image files not exist in path and open report this is actually what i need
    my code below as following
    DataTable dt = new DataTable();
    string connString = "data source=192.168.1.105; initial catalog=hrdata;uid=sa; password=1234";
    using (SqlConnection con = new SqlConnection(connString))
    con.Open();
    SqlCommand cmd = new SqlCommand("ViewEmployeeNoRall", con);
    cmd.CommandType = CommandType.StoredProcedure;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    da.Fill(dt);
    foreach (DataRow dr in dt.Rows)
    FileStream fs = null;
    fs = new FileStream("\\\\192.168.1.105\\Personal Pictures\\" + dr[0] + ".jpg", FileMode.Open);
    BinaryReader br = new BinaryReader(fs);
    byte[] imgbyte = new byte[fs.Length + 1];
    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
    dr["Image"] = imgbyte;
    fs.Dispose();
    ReportDocument objRpt = new Reports.CrystalReportData2();
    objRpt.SetDataSource(dt);
    crystalReportViewer1.ReportSource = objRpt;
    crystalReportViewer1.Refresh();
    and exception error as below

    First: I created a New Column ("Image") in a datatable of the dataset and change the DataType to System.Byte()
    Second : Drag And drop this image Filed Where I want.
    private void LoadReport()
    frmCheckWeigher rpt = new frmCheckWeigher();
    CryRe_DailyBatch report = new CryRe_DailyBatch();
    DataSet1TableAdapters.DataTable_DailyBatch1TableAdapter ta = new CheckWeigherReportViewer.DataSet1TableAdapters.DataTable_DailyBatch1TableAdapter();
    DataSet1.DataTable_DailyBatch1DataTable table = ta.GetData(clsLogs.strStartDate_rpt, clsLogs.strBatchno_Rpt, clsLogs.cmdeviceid); // Data from Database
    DataTable dt = GetImageRow(table, "Footer.Jpg");
    report.SetDataSource(dt);
    crv1.ReportSource = report;
    crv1.Refresh();
    By this Function I merge My Image data into dataTable
    private DataTable GetImageRow(DataTable dt, string ImageName)
    try
    FileStream fs;
    BinaryReader br;
    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + ImageName))
    fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageName, FileMode.Open);
    else
    // if photo does not exist show the nophoto.jpg file
    fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + ImageName, FileMode.Open);
    // initialise the binary reader from file streamobject
    br = new BinaryReader(fs);
    // define the byte array of filelength
    byte[] imgbyte = new byte[fs.Length + 1];
    // read the bytes from the binary reader
    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
    dt.Rows[0]["Image"] = imgbyte;
    br.Close();
    // close the binary reader
    fs.Close();
    // close the file stream
    catch (Exception ex)
    // error handling
    MessageBox.Show("Missing " + ImageName + "or nophoto.jpg in application folder");
    return dt;
    // Return Datatable After Image Row Insertion
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • When creating a table why should we give promary key

    when creating a table why should we give promary key

    Hi Rambabu,
    Primary key is needed so as to avoid duplicate entries and ensure that there are unique entries in the table.
    For some applications, it is useful to uniquely identify the rows in a table by one or more columns so that you can process them in a specified sequence, for example. You can do this by assigning a “primary key.” The column names that are to create the table key are represented by the keywords PRIMARY KEY. The input values of the key columns defined in this way must not be a NULL value.
    You can use the primary key to insert rows in a table in the same way as you insert rows in a base table when no primary key is defined. However, the system outputs an error message if you attempt to insert an existing value into the primary key column a second time, since the uniqueness of the column is ensured by defining the primary key.
    A primary key can consist of multiple columns. However, it is unusual for a key to be constructed from more than five columns, since this makes it difficult for users to enter unique values. The arrangement of the columns behind the keywords PRIMARY KEY defines the key sequence.
    Regards,
    Sekhar

  • 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

  • Why does itunes give an error saying " The Iphone cannot be synced. An unknown error occured (-50). Everytime I try to sync my phone?

    Why does itunes give an error saying " The Iphone cannot be synced. An unknown error occured (-50)". Everytime I try to sync my phone? I have another Iphone that syncs with the same itunes account and it's working fine.

    What operating system do you have on your computer?

  • Interaction Record cannot be displayed, instead it gives an exception error

    Hi Folks,
    In the Web IC, when I click on "Interaction Record" in the Navigation bar, the page is not displayed, instead it gives an exception error:
    Component ICCMP_BT_INR cannot be displayed
    An exception has occurred Exception Class  CX_BOL_EXCEPTION - Access Previously Deleted Entity 
    Method:  CL_CRM_BOL_CORE=>GET_TRANSACTION 
    Source Text Row:  10
    Can someone tell me where to correct this situation.
    Thanks,
    John

    Hi,
    please check this setting:
    SPRO->IMG->Customer Relationship Management->Transactions->Basic Settings->Define Transaction Type
    Define 0010 as default for IR.
    Denis

  • Why we should give currency type 30 in 2nd local currency ?

    Hi,
    why we should give currency type 30  2nd local currency in Define Currencies of Leading Ledger. Here 30 indicates EUR only. I want to give USD as 2nd local currency.
    Please suggest.
    Thanks,
    Gangaraju

    Group currency is unique at client level, i.e. this is same for all company codes.
    go to scc4
    Check the currency of your client.
    This currency comes by default for group currency and you can't give as your own.
    If you have any requirement, then you can give it as third local currency.
    Also remember third local currency you have to maintain at first country level.
    Rgds
    Murali. N

  • Why the system gives 1st priority to doc type for shipping con value

    Hi gurus
    I want to know one thing,
    When we create a sales order the system take the shipping condition value from the doc type first,if it does not get any value then only it serch customer master for the value.
    I just want to know that why the system gives first priority to doc type shipping con value?
    What is the reason behind it?
    it was asked me in an interview
    Please give me the ans.
    Thanks And Regards
    Babi
    Edited by: babisap on Mar 30, 2010 7:26 AM

    Hi Babi,
    Mostly SAP systems are built in such a way that it gives you control for same functionality at various levles.In your case if you configure the shipping conditions at the document type then (irrespective of what shipping conditions are maintainned at customer master)they are defaulted .This is required to default shipping conditions for some perticular business scenarios like all rush orders to be shipped from express shipping point.
    But if yoiu do not want the more generic control then the same can be at customer master level.
    Regards,
    Vishwajit

  • Why need to give Function group at time of  table maintence generation

    Dear All,
    why need to give Function group at time of  table maintence generation
    Regards,
    Laxman  Sankhla

    Hi Laxman,
    The F1 help of the field says:
    Name of the function group, to which the generated maintenance modules will belong.
    Means the PBO & PAI modules of the screen will be created under this Functio group.
    Regards
    DKS

  • Why we have give in where clause  1=1

    hi,
    why we have give in select statement ------ where clause 1=1 and follow by conditions ...
    thanks in advance ....

    * moderators hat on *
    Naveed_CG wrote:
    Report abuse about this sb92075 user by clicking the small yellow icon on his reply ... he is wasting the time and valuable learning and suggestions from others.It is not abuse, it's a valid point.
    The forum is a community of volunteers who are willing to help people who have genuine issues and who provide proper feedback.
    The OP has been a member for nearly 2 years and has 225 posts to their name. Of those 225 posts, 143 of them are questions they've asked, which a quick bit of easy mental maths tells you that for at least some of those questions they've asked the question and never responded to any of the answers they've been given. On top of that, of the 143 questions, 112 of them are still showing as unresolved, indicating that they are either not asking questions in a way that people can answer them, or that they are not marking their questions as answered when they receive an answer. There's a thing called Forum Etiquette, and this member is clearly showing that they are not following it.
    Also, sb92075 is not preventing anyone else from providing valuable suggestions or stopping anyone from learning. If anything, asking questions to which the answers can be found easily on the internet ( http://lmgtfy.com/?q=where+1%3D1 ) could very easily be seen as an abuse and waste of the volunteers time, and detracting from other members with valid issues to be resolved.
    * moderators hat off *

  • When adjusting the audio volume in a selected region, why does it give me a curved line instead of straight and why cant I change it like i can with a fade in our out?

    When adjusting the audio volume in a selected region, why does it give me a curved line as a transition instead of straight, and why cant I change the fade shape like i can with a fade in our out? When I slide thet volume all the way down it makes a very abrupt down curve. It's audibly noticdible.
    Thank you.

    Use the range selection tool and select the portion of the clip you want to change the volume on. Drag the volume line down and FCP will create keyframes which you can adjust as you want to get a fade shape.

  • I have a local LAN DNS server. My preferences point to that server. Why does dig give me 8.8.8.8 as my DNS server?

    I have a local LAN DNS server. My preferences point to that server. Why does dig give me 8.8.8.8 as my DNS server?
    Something is/was modifying my DNS preferences to 8.8.8.8 It seems to be pointed correctly now (at my local LAN DNS server), but why was it pointed at 8.8.8.8 before? I never want it pointed to 8.8.8.8

    You've hit the nail on the head Ben.  For point to point communications, the IP addresses should be fixed, therefore there is no need for DNS.  If a DNS is configured, the NIC (Network Interface Card) drivers will try to contact it.
    In my test system, I need DNS for the test computer, but I am communicating with a dedicated Spectrum Analyzer over TCP/IP.  So I added a second NIC.  The main NIC is configured for DNS and all that jazz.  The second NIC (plugged into PCI slot) is configured with a hard coded address, no DNS, no Gateway, nothing else.  I connect that NIC to the spectrum analyzer using a crossover cable.  The analyzer is configured with a hard coded address also.  Now my computer can get on our company network, and the spectrum analyzer is isolated from the network, so it can't catch any viruses, etc., and it still talks to the computer.  When using a configuration such as this, it is best to use a dedicated address for the 2nd NIC and spectrum analyzer in the range of 192.168.100.0 to 254
    - tbob
    Inventor of the WORM Global

  • Why does Firefox give this message when I do not have another program running "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system."

    Question
    why does Firefox give this message when I do not have another program running or another window open - "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system." edit

    See also "Hang at exit":
    *http://kb.mozillazine.org/Firefox_hangs
    *https://support.mozilla.com/kb/Firefox+hangs

  • Why should we give credit card details to open account even before any purchase

    Why should we give credit card details to open account even before any purchase

    Setup iTune account without credit card
    http://support.apple.com/kb/ht2534

  • Why Apple not give option on Whatsapp to send Music file?

    Dear Team,
    Why Apple not give option on Whatsapp for sending Music file? I am using sone trick but when i send music file via whatsapp other person download it but some time music file not played because of file not supported. What is easy way to send music file via Whatsapp with right format. If not any way then Apple should to look on Audio and give option to save audio file on camera roll so that we can easy to send audio file via whatsapp or any other social media software like picture and videos.

    Hi there,
    But I have a question - Any Audio file thats sent over an android is being saved without any challenge & Whatsapp is not a product of Android or HTC ( Since i was using HTC one X previously), So - i dont agree with your statement - please clarify & Help,
    Or you mean to say that - Whatsapp must tweek their settings to get it functional with iphone or ipad ??

Maybe you are looking for

  • Simple creation of Update Rule from BW Data Source

    Hi guys,    Pertaining standard SAP Business Content extractors    I am referring to <b>InfoCube : 0PA_C01(Headcount and Personnel Actions)</b>    I am attempting to<u> create </u>an <b>Update Rule</b> from <b>Info Source : 0HR_PA_PA_1(Headcount)</b>

  • Unable to log in to the FileVault user account

    I was unable to log in to the FileVault user account at this time because an error occurred. Q.1: What is FileVault user account? I can't reset a new password and to unlock FileVault even my master password is correct. Q.2: What can I do to solve thi

  • Lighroom crashes every time I try to email

    I am using Windows 7 64 bit, lightroom 5.3 and I suspect that this problem has started since I installed Outlook 2013.  I have tried reinstalling lightroom and even deleting the preference file with no success.  I have noticed that other people are h

  • Display the value in millions

    Hi,     I am designing a pie chart, the output value of the pie chart should be display as 72%($2.75Mil) but it was displaying as 72%(2,752,852). I used the format as 0,,;(0,,) and expression as =" #PERCENT{P0}" & VbCrlf & "("&FormatCurrency(IIF(IsNo

  • How to show rss from other sites on my site?

    how to show rss from other sites on my site? i'd like to have a window on my site that shows rss from another site (their content in a window on my site) thanks lenny