Inser Data in to CLOB using BC4J

Hi
I am going thru the docs by oracle for data insertion into CLOB.
in the method getCLOB(String data,Connection conn) how do we get the Connection object when we are using BC4J.
Any help ..
Thanks

This does not work when the Atribute is set to mandatory in the Entity Object.
It works fine when it is not mandatory. This is a bug .

Similar Messages

  • How to convert blob data into clob using plsql

    hi all,
    I have requirement to convert blob column into clob .
    version details
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    DECLARE
       v_blob      temp.blob_column%TYPE;------this is blob data type column contains  (CSV file which is  inserted  from screens)
       v_clob      CLOB; --i want to copy blob column data into this clob
       v_warning   NUMBER;
    BEGIN
       SELECT blob_column
         INTO v_blob
         FROM temp
        WHERE pk = 75000676;
       DBMS_LOB.converttoclob (dest_lob          => v_clob,
                               src_blob          => v_blob,
                               amount            => DBMS_LOB.lobmaxsize,
                               dest_offset       => 1,
                               src_offset        => 1,
                               blob_csid         => 1, -- what  is the use of this parameter
                               lang_context      => 1,
                               warning           => v_warning
       DBMS_OUTPUT.put_line (v_warning);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SQLCODE);
          DBMS_OUTPUT.put_line (SQLERRM);
    END;I am not getting what is the use of blob_csid , lang_context parameters after going the trough the documentation .
    Any help in this regard would be highly appreciated .......
    Thanks
    Edited by: prakash on Feb 5, 2012 11:41 PM

    Post the 4 digit Oracle version.
    Did you read the Doc for DBMS_LOB.CONVERTTOCLOB? - http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm
    The function can convert data from one character set to another. If the source data uses a different character set than the target you need to provide the character set id of the source data.
    The blob_csid parameter is where you would provide the value for the source character set.
    If the source and target use the same character set then just pass zero. Your code is passing a one.
    >
    General Notes
    You must specify the character set of the source data in the blob_csid parameter. You can pass a zero value for blob_csid. When you do so, the database assumes that the BLOB contains character data in the same character set as the destination CLOB.
    >
    Same for 'lang_context' - your code is using 1; just use 0. It is an IN OUT
    >
    lang_context
    (IN) Language context, such as shift status, for the current conversion.
    (OUT) The language context at the time when the current conversion is done.
    This information is returned so you can use it for subsequent conversions without losing or misinterpreting any source data. For the very first conversion, or if do not care, use the default value of zero.

  • Storing Chinese data as clob using dbms_xmlquery

    Hi,
    I am writing a procedure that creates a query and same is stored as CLOB in a database table. Below is a sample test program for same. I am using UTF-8 to accomodate Chinese data. The CLOB however doesn't contain valid chinese data. Please guide me on what needs to be done....
    declare
    l_ctx dbms_xmlquery.ctxtype;
    l_xml_schema NCLOB;
    begin
    l_ctx := dbms_xmlquery.newcontext('SELECT * FROM (SELECT "SEC","coretypeid","coreid","Record Type","您ID" FROM (SELECT "您MultiCurrency Object".coreid "SEC","您MultiCurrency Object".coretypeid "coretypeid", "您MultiCurrency Object".coreid "coreid", "您MultiCurrency Object".CoreTypeAssocAliasDescr "Record Type", "您MultiCurrency Object".F_3441961635 "您ID"
    FROM ( SELECT SUBSTR(RFN_FlexSQL_Cache.GetCTAliasDescr(CORETYPEID,3441940070,3443315783),0,50) CoreTypeAliasDescr,
    SUBSTR(RFN_FlexSQL_Cache.GetCTAssocAliasDescr(CORETYPEID,3441940070,3443315783),0,50) CoreTypeAssocAliasDescr,
    SUBSTR(RFN_FlexSQL_Cache.GetCTDescr(CORETYPEID,3441940070,3443315783),0,50) COREDESCRIPTION,
    COREID, CORETYPEID ,F_3441961635 FROM CT_3420185025
    WHERE coretypeid IN (3420185025)) "您MultiCurrency Object" )) WHERE 1 = 2');
    dbms_xmlquery.setraiseexception(l_ctx, TRUE);
    dbms_xmlquery.setsqltoxmlnameescaping(l_ctx, TRUE);
    -- dbms_xmlquery.setdateformat(l_ctx, l_xml_sformat);
    dbms_xmlquery.setencodingtag(l_ctx, 'ISO-8859-1');
    l_xml_schema := dbms_xmlquery.getxml(l_ctx,2);
    insert into testingXMLgen values (l_xml_schema);
    -- :xml_data := dbms_xmlquery.getxml(l_ctx);
    dbms_xmlquery.closecontext(l_ctx);
    end;

    I have tried UTF-8 encoding set as well. It didn't work toodbms_xmlquery.setencodingtag(l_ctx, 'UTF-8');
    Corresponding database column is NCLOB
    select * from nls_database_parameters;PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET WE8ISO8859P1
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    PARAMETER VALUE
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_RDBMS_VERSION 10.2.0.5.0
    20 rows selected.

  • Creating rows Using BC4J Data Tags

    Hi!
    I want to create rows using BC4J data tags.
    I have 2 jsp pages: one containig forms and one to insert data.
    Is it possible to insert new rows into 2 or more tables?
    How can I differ the attributes to one table and to another?
    How can I do this?
    Thanks!

    The path is:
    Select "File/New" in the menu.
    Select "BC4J JSP" in the gallery.
    Select "Browse & Edit Form" wizard.
    This is in JDeveloper 9.0.2.
    Charles.

  • HOWTO: Use BC4J With or Without DB Triggers

    This HowTo describes how to use BC4J, database sequences and triggers
    and what are the ramifications.
    INTRODUCTION
    BC4J has the ability to work with database sequences in order to obtain a
    unique value when inserting records. BC4J also has the ability to
    work either with a 'before insert' trigger which automatically creates
    a new unique value for the primary key or without a trigger. When not using
    a database trigger, BC4J also has the ability to obtain the sequence value
    and set the primary key value.
    Before discussing the ramifications of using one approach or the other, let's
    show examples of how to use both approaches:
    BC4J & sequences WITH a database trigger
    and
    BC4J & sequences WITHOUT a database trigger
    HOWTO DEMONSTRATION STEPS
    To illustrate both scenarios a simple database setup script is provided which
    creates two tables:
    CUSTOMER_NT which DOES NOT have a before insert trigger and
    CUSTOMER_WT which DOES have a trigger.
    Database Install Script:
    <code>
    drop trigger customer_insert_trigger;
    drop table customer_wt;
    drop table customer_nt;
    drop sequence customer_wt_seq;
    drop sequence customer_nt_seq;
    create sequence customer_wt_seq start with 1;
    create sequence customer_nt_seq start with 101;
    create table customer_wt(
    id number,
    name varchar2(30),
    constraint
    customer_wt_pk
    primary key (id)
    create table customer_nt(
    id number,
    name varchar2(30),
    constraint
    customer_nt_pk
    primary key (id)
    prompt Inserting data...
    insert into customer_wt (id, name)
    values (customer_wt_seq.nextval, 'Mickey');
    insert into customer_wt (id, name)
    values (customer_wt_seq.nextval, 'Goofy');
    insert into customer_nt (id, name)
    values (customer_nt_seq.nextval, 'Daffy');
    insert into customer_nt (id, name)
    values (customer_nt_seq.nextval, 'Porky');
    commit
    prompt Creating trigger
    create trigger customer_insert_trigger
    before insert on customer_wt for each row
    begin
    select customer_wt_seq.nextval into :new.id from dual ;
    end;
    </code>
    The next step is to create the DEFAULT Entity Objects and View Objects using
    the Business Components Wizard.
    USING BC4J WITH A DATABASE TRIGGER
    Let's modify the entity object CustomerWt so it can use the database trigger.
    Edit the entity object CustomerWt by right-clicking in the navigator.
    Click on the 'Attribute Settings' tab and edit the ID attribute.
    - Uncheck 'Mandatory'checkbox. This allows you to insert without a value for the primary key
    - Check 'Refresh after Insert'. This obtains the value from the database generated by the trigger.
    - Check 'Updateable While New'. Id is only updateable when inserting.
    Click finish to complete the wizard. Save all and recompile the project.
    Now let's test our work.
    In the navigator right-click the application module and select 'Test..'. This will launch
    BC4J's built in tester. Connect to the application.
    In the tester double-click the CustomerWtView view object to run a test edit form.
    After the edit form renders, navigate through the existing records using the navigate
    buttons on the edit form. Now let's insert a record to execute the trigger.
    click on the '+' button to insert a record. Enter a value in the 'Name' field and commit the change.
    Observe that a new value has automatically been inserted into the Id field.
    That's it! You have successfully used BC4J and a database trigger.
    Now let's try it without a trigger..
    USING BC4J WITHOUT A DATABASE TRIGGER
    Now edit the entity object CustomerNT so it doesn't need a database trigger.
    Similar to before, edit the entity object CustomerNt by right-clicking in the navigator.
    Click on the 'Attribute Settings' tab and edit the ID attribute.
    - Uncheck 'Mandatory'checkbox.
    - Check 'Updateable While New'.
    An additional step is also required. The Create method will have to be modified to extract
    the value of the sequence.
    In the Edit EntityObject Wizard click the Java tab and select Create method and click Finish.
    The create method is generated in your Java fil e. In the Workspace view of the Navigator,
    expand the CustomerNt entity object in the navigator. Double-click
    CustomerNtImpl.java to open it in the Source Editor. In the Structure pane, double-click
    create(AttributeList). Modify the Create method so it looks like this:
    <code>
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("customer_nt_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue())); }
    </code>
    Save and compile the project.
    Now test the ViewObject CustomerNtView using the tester as before.
    In the edit form of CustomerNTView click on the '+' to insert a record. Observe that
    just as before a new value has automatically been inserted in the ID field!
    TO USE A DB TRIGGER OR NOT TO USE A DB TRIGGER.
    Using a Database trigger sometimes preferable if you have non BC4J applications
    also sharing the database. In this case it is still safest to just let the database
    update it's own primary keys.
    If you don't have any other non-BC4J applications sharing the database, then not using
    a database trigger is perfectly acceptable and can have slightly better performance.
    The important thing to remember is that the option is yours to use either approach!
    null

    Thank you for the reply Jonathon. I am using a ViewObject which
    consist of several tables. I haven't tried the DB trigger
    approach but just using the BC4 approach in overriding the
    create method.
    Here is the parent class create as a part of the
    FasNameImpl.java file which does the job correctly.
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl l_seq = new SequenceImpl
    ("SEQ_CUSTOMER_ID",getDBTransaction());
    Integer l_next = (Integer)l_seq.getData();
    setCustomerId(new Number(l_next.intValue()));
    This is when I triedpassing the value to the child table. But I
    can't figure it out. I think the link is working fine if I had a
    ViewLink deployed but it doesn't look like it's doing the job
    for ViewObject.
    I am trying to call the childclass.method
    (FasCustomer.setCustomerId(l_next);
    But I am getting error.
    Thanks a lot for your suggestions,
    Kamran
    703 696 1121

  • How to write a procedure to load the data into a table using xml file as input to the procedure?

    Hi,
    Iam new to the xml,
    can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
    <?xml version="1.0"?>
    <DiseaseCodes>
    <Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    </DiseaseCodes>.
    Regards,
    vikram.

    here is the your XML parse in 11g :
    select *
      from xmltable('//Entity' passing xmltype
    '<?xml version="1.0"?>
    <DiseaseCodes>
    <Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    </DiseaseCodes>
    ') columns
      "dcode" varchar2(4000) path '/Entity/dcode',
      "ddesc" varchar2(4000) path '/Entity/ddesc',
      "reauthflag" varchar2(4000) path '/Entity/reauthflag'
    dcode                                                                            ddesc                                                                            reauthflag
    0                                                                                (I87)Other disorders of veins - postphlebitic syndrome                           0
    0                                                                                (J04)Acute laryngitis and tracheitis                                             0
    0                                                                                (J17*)Pneumonia in other diseases - whooping cough                               0
    SQL>
    Using this parser you can create procedure as
    SQL> create or replace procedure myXMLParse(x clob) as
      2  begin
      3    insert into MyXmlTable
      4      select *
      5        from xmltable('//Entity' passing xmltype(x) columns "dcode"
      6                      varchar2(4000) path '/Entity/dcode',
      7                      "ddesc" varchar2(4000) path '/Entity/ddesc',
      8                      "reauthflag" varchar2(4000) path '/Entity/reauthflag');
      9    commit;
    10  end;
    11 
    12  /
    Procedure created
    SQL>
    SQL>
    SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
    PL/SQL procedure successfully completed
    SQL> select * from MYXMLTABLE;
    dcode                                                                            ddesc                                                                            reauthflag
    0                                                                                (I87)Other disorders of veins - postphlebitic syndrome                           0
    0                                                                                (J04)Acute laryngitis and tracheitis                                             0
    0                                                                                (J17*)Pneumonia in other diseases - whooping cough                               0
    SQL>
    SQL>
    Ramin Hashimzade

  • Apex.ajax.clob - retrieving data from a clob field

    I have an application that uses a table that stores xml data, and the field in the table that stores the data is a clob. I used Carl Backstrom's example to build what I have so far, (God's blessings on his family). Here is the script I use to store the data from an HTML Editor into the database:
    function clob_set(request){
    var oEditor = FCKeditorAPI.GetInstance('P59_CONTENT');
    var clob_ob = new apex.ajax.clob(
    function(){
    var rs = p.readyState
    if(rs == 1||rs == 2||rs == 3){
    $x_Show('AjaxLoading');
    }else if(rs == 4){
    $x_Hide('AjaxLoading');
    $s('P59_CONT', p.responseText);
    doSubmit(request)
    }else{return false;}
    $x('P59_CONT').value = oEditor.GetHTML();
    oEditor.SetHTML('');
    if(!$v_IsEmpty('P59_CONT')){clob_ob._set($v('P59_CONT'))};
    The submit calls a process that inserts the data from the clob001 field in the CLOB_CONTENT collection into my table.
    How do I get the data out of the table again to present in the HTML Editor? Each option I use gets me into trouble with the 32k length limitation that is extant in Apex. What would be the best way to address this?

    Inserting or retrieving a clob in the database is simple and can be done with a pl/sql process. It gets more more complex when the clob is large; I believe the limit is 32k? Larger than that and the HTTP process cannot manipulate the data stream.
    The key to manipulating clobs successfully is through the use of collections, and javascript. In my case, I used the standard html editor item (fckeditor) to retrieve the data and present it on the page through the apex.ajax.clob javascript function. The clob_set method in the apex.ajax.clob function that I mention in the previous sections of this post calls the 'doSubmit(request)' that causes a pl/sql function to be fired that writes the clob to the database from the collection created by the clob_get method. The collection that the clob_get method creates is called 'CLOB_CONTENT', and can be accessed through the 'apex_collections' view through standard sql within APEX. In my case, the pull the 'clob001' field from the 'CLOB_CONTENT' collection after the clob_set method runs, and I insert the value from 'clob001' into the table I have created for storing the clob content. The clob_set pulls the data from the HTML editor (FCKeditorAPI.GetInstance('P59_CONTENT')) through the GetHTML() method that is part of the FCKeditorAPI.
    function clob_set(request){
    var oEditor = FCKeditorAPI.GetInstance('P59_CONTENT');
    var clob_ob = new apex.ajax.clob(
    function(){
    var rs = p.readyState
    if(rs == 1||rs == 2||rs == 3){
    $x_Show('AjaxLoading');
    }else if(rs == 4){
    doSubmit(request);
    $x_Hide('AjaxLoading');
    }else{return false;}
    var p_html = oEditor.GetHTML();
    if (p_html){
    clob_ob._set(p_html);
    else {
    p_html = ' '
    clob_ob._set(p_html);
    The clob_get method pulls the data from the 'CLOB_CONTENT' collection and puts it into the html editor item I have created, performing the process in reverse. The primary difference with reversing the process is that a pl/sql function is created that populates the clob001 field in the 'CLOB_CONTENT' collection prior to the clob_get function firing:
    declare
    l_clob clob:= empty_clob();
    begin
    if apex_collection.collection_exists(p_collection_name=>'CLOB_CONTENT') then
    apex_collection.delete_collection(p_collection_name=>'CLOB_CONTENT');
    end if;
    apex_collection.create_or_truncate_collection(p_collection_name=>'CLOB_CONTENT');
    dbms_lob.createtemporary( l_clob, false, dbms_lob.SESSION );
    if trim(:P123_ID) <> 0 then
    select
    nvl (ltr,'There is no letter assigned.')
    into
    l_clob
    from grant_tbl
    where id = to_number(:P123_ID);
    apex_collection.add_member(p_collection_name => 'CLOB_CONTENT'
    ,p_clob001 => l_clob
    ELSE
    apex_collection.add_member(p_collection_name => 'CLOB_CONTENT'
    ,p_clob001 => 'You must select an item to view its letter.');
    end if;
    end;
    The clob_get function is below. Notice that the line "$s('P123_CONTENT',p.responseText);" is taking the output from the clob_get and setting the value of the P123_CONTENT page item (which is my standard html editor item) with the 'responseText'. the 'p' object and the 'responseText' method are built into the clob_get function when a 'new apex.ajax.clob' object is created. Confusing? Tell me about it!
    function clob_get(){
    var clob_ob = new apex.ajax.clob(
    function(){
    var rs = p.readyState
    if(rs == 1||rs == 2||rs == 3){
    null;
    }else if(rs == 4){
    $s('P123_CONTENT',p.responseText);
    null;
    }else{return false;}
    clob_ob._get();
    }

  • Can I create an XSD from XML data in a CLOB?

    Environment:
    Oracle 11.2.0.3 EE on Solaris.
    Very much an XML newbie so please be kind! 
    I have spent the past few days pouring through the documentation and various blogs, especially this one, but ... I need some help.
    I am trying to extract XML data stored in a CLOB and produce a flat file for the user's consumption.
    They have sent me what they think is the XSD for the XML data but when I look at the data in the CLOB I don't see the tags documented in the XSD.
    I'd like to produce an XSD based on the actual data to compare with what they've sent.
    Is this possible?
    I am able to query the XML data using the tags I see in the data using XMLTable and it's working fine.
    Any help is greatly appreciated.
    -gary

    Welcome to the XML side of the world, where you will love it and curse it, just like any other piece of technology.
    So as I understand it, the scope of your operation is to extract information from an XML file and then write that information to disk, correct?
    Some questions
    - Why is the XML stored in a CLOB instead of an XMLType column?  Without knowing the system history, it is a valid question.
    - How big are the XML?  The reason I ask this is because when the XML is stored in XMLType columns (of Object Relational structure or SECUREFILE BINARY XML format), then Oracle can parse the XML substantially easier than when it is stored as a CLOB.  If the XML is fairly small, you may see no performance difference between the two.
    The Oracle DB itself has no built in ability to generate a schema from an XML file.  In order to do that, you would need to use some third party tool that has that functionality built in.  For example, XML Spy can do this.  Other tools can as well, but that is what came to mind first as it is what I use.  The one thing to remember is that the schema it builds represents that one instance of XML.  Other instances of XML may be different and not validate against the schema you generated, but still have been valid against the unknown original schema.
    You can register the schema in the database and then use the XML to create an XMLType instance associated to the schema and then validate the XML that way.  One example can be found at XML DB FAQ and here is another example Re: XML Schema validation
    Hope that helps you continue on.

  • Creating af:Table programatically : XML Data coming from CLOB

    Hi ,
    This is my Use case ::
    JDev version :: 11.1.2.3
    I am presenting my use case in XE database format.
    1) We have a procedure say:
    PROCEDURE GET_EMP_FOR_DEPT(DeptId IN Number,XMLDeptData OUT CLOB);
    based on DeptId Input it returns the Employees Under Department.
    2) Have created JaxB class using xsd say EmpUnderDeptDataSet.java
    3) I have created method for calling this proc and and receiving the CLOB as output in the object of Type
       EmpUnderDeptDataSet , in AMImpl class
    4) We don't have the choice for creating EJB or other Data Control....and Programmatic EO..VO...
       So added method to expose the Data received as List using client Interface in AMImpl
        public List<EmpUnderDeptDataSet> getEmpUnderDeptCollection();
    5) Now we need to have 1 Page where on Left Panel we have LOV to select the Dept.
    On right panel, based on DeptId selected we have to show the Table of Employees returned
    by the procedure.Refreshed every time the DeptId changes
    Also, the Left Panel has to be Region.
    How can we implement this. Please advise.

    Use the EXTRACTVALUE SQL function.
    XMLType Operations

  • How to read XML data stored in CLOB in Concurrent prog Output

    Hi All,
    I'm trying to Generate the XML Data as concurrent Program output. I have a PL/SQL package which generated the XML data by using SQL/XML functions. I'm storing the generated XML data in a CLOB variable. But when i try to read the data using fnd_file.put_line(fnd_file.OUTPUT,XML_Data) it doesn't display data more than 32767 bytes.
    Please help me out to understand what could be done to read the data in chunks. I have tried many logic's to print chunks of data but the output tags are either chopped off and errors out saying Tag not found.
    My logic is as below:
    v_handler:= DBMS_XMLGEN.newContext(v_xml_query);
    --Sets NULL handling options
    DBMS_XMLGen.SetNullHandling(v_handler, dbms_xmlgen.EMPTY_TAG ) ;
    --Set special character handling
    DBMS_XMLGEN.setConvertSpecialChars(v_handler, TRUE);
    -- Specified whether to use an XML attribute to indicate NULLness of particular entity in the XML document
    DBMS_XMLGen.useNullAttributeIndicator(v_handler,TRUE);
    -- set Checking invalid chars
    DBMS_XMLGEN.setCheckInvalidChars(v_handler, TRUE);
    -- get the xml data as required
    v_xml_data:= DBMS_XMLGEN.getXMLtype(v_handler);
    SELECT XMLROOT(v_xml_data.extract('/*'),VERSION '1.0').getClobVal() into v_new_xml_Data from dual;
    -- get the length of the xml generated
    v_clob_len := dbms_lob.getlength(v_new_xml_Data);
    FND_FILE.PUT_LINE(FND_FILE.LOG,'The Clob length is :'|| v_clob_len);
    -- logic to process string more than 32767 Processing by each character
    v_offset :=1;
    while (v_offset <= v_clob_len)
    LOOP
    v_char := dbms_lob.substr(v_new_xml_Data, 1, v_offset);
    IF (v_char = CHR(10))
    then
    fnd_file.new_line(fnd_file.output, 1);
    else
    fnd_file.put(fnd_file.output, v_char);
    end if;
    v_offset := v_offset + 1;
    END LOOP;
    FND_FILE.PUT_LINE(FND_FILE.LOG,'The offset is :'|| v_offset);
    FND_FILE.NEW_LINE(FND_FILE.OUTPUT, 1);
    THe above logic is for character by character which is a performance burden? Please let me know if there is any other work around for this

    Hi,
    Thanks for Replying. I have refered http://blog.oraclecontractors.com/?p=69 and then i added that piece of code. Basically, i'm trying to generate a report using XML publisher. To generate the XML data i'm writing a pl/sql package with SQl/XML functions. DBMS_XMLGEN would help me convert the XML Data as is. When the concurrent program runs this XML data will merge with RTF layout and generate required report. I'm able to generate the Report for data less then 32767 bytes. More than the limit i need to pass chunks of XML data to read as output. That's the reason i'm using fnd_file.output. But it reads only 32767 size at a time.
    WHen i use the given logic, it works perfectly fine, but it loops for each character, for example if you have 30,000 characters it loops the same, which is peformance burden.
    So i tried to write the logic of chunks but still i get the error that XML tag is not found or missing. I'm hoping this is very common issue, but after all my trails, i didn't find the right solution.
    the other logic i tried was :
    v_new_xml_data varchar2(32767)
    v_iterations := CEIL(v_clob_len/v_chunk_length); -- v_chunk_length is 32767 and v_clob_length is length of the XML data stored inthe clob variable
    For i in 0..v_iterations
    LOOP
    FND_FILE.put_line (fnd_file.log,'the loops v_pos :'||i||' and v_clob_length :'||v_clob_len);
    v_new_xml_data := DBMS_LOB.SUBSTR ( V_XML_DATA,v_chunk_length,(i*v_chunk_length)+1);
    FND_FILE.PUT_LINE (FND_FILE.OUTPUT,v_new_xml_data); -- read the output for every 32767 chunks
    FND_FILE.PUT_LINE(FND_FILE.LOG, 'Chunk length is :'||((i*v_chunk_length)+1));
    END LOOP;
    FND_FILE.put_line (fnd_file.log,'out of loop');
    FND_FILE.put_line (fnd_file.log,'length of new xml is '||v_clob_len);
    Please, let me know if you need Further clarifications on the same.

  • Update XML data stored in CLOB Column

    Hi All,
    i am new to Oracle and new to SQL
    i am trying to update XML data stored in CLOB cloumn,data is stored with the follwoing format
    <attrs><attr name="name"><string>Schade</string></attr></attrs>
    i am using the following query for updating the value
    UPDATE PRODUCT p SET ATTRIBUTES_nl_nl=UPDATEXML(XMLTYPE.createXML(ATTRIBUTES_nl_nl),'/attrs/attr[@name="name"]/string/text()','Schade').getClobVal() WHERE p.sku='000000000000040576_200911-5010057'
    this query is working fine but it changing the data to the following format
    <attrs><attr name="name">Schade</attr></attrs>
    some how it is ommiting the <string> tag from it, i am unable to figure it out whats the reason.
    any help in this regard will b e much appriciated
    Thanks in Advance
    -Umesh

    Hi,
    You should have created your own thread for this, and included database version.
    This works for me on 11.2.0.2 and 10.2.0.5 :
    SQL> create table t_org ( xml_clob clob );
    Table created
    SQL>
    SQL> insert into t_org
      2  values(
      3  '<Message>
      4  <Entity>
      5  <ASSIGNMENT>
      6  <OAVendorLocation> </OAVendorLocation>
      7  <Vendorid>1</Vendorid>
      8  </ASSIGNMENT>
      9  </Entity>
    10  </Message>'
    11  );
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> select '*' ||
      2         extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
      3         || '*' as result
      4  from t_org;
    RESULT
    SQL> update t_org set xml_clob =
      2  updatexml(xmltype(xml_clob),
      3  '/Message/Entity/ASSIGNMENT/OAVendorLocation/text()','LONDON').getClobVal()
      4  ;
    1 row updated
    SQL> select '*' ||
      2         extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
      3         || '*' as result
      4  from t_org;
    RESULT
    *LONDON*
    Does the OAVendorLocation really have a whitespace value?
    If not then it's expected behaviour, you're trying to update a text() node that doesn't exist. In this case, the solution is to use appendChildXML to create the text() node, or update the whole element.
    Is it your real document? Do you actually have some namespaces?

  • Most robust way to preserve data insert into CLOB?

    Hello.
    When inserting data into a CLOB column, some of the characters are not being preserved, such as ellipsis characters and other unusual characters. The data is being inserted via JDBC as a simple Java string sql statement in a Statement object. So, what is the most appropriate way to insert information into a CLOB such that all characters are preserved? (Do I have to use PreparedStatements or Clob.setString()?)
    For example, the following sql insert:
    "INSERT INTO t1 (myClob) VALUES ('Hello ... how are you?');"
    Will end up inserting something like:
    "Hello ? how are you?"
    The ellipsis character (Unicode U+2026, I believe) is changed to something else. How can I preserve this and other characters? Thanks in advance.

    Hi,
    Must have something to do with NCHAR or Unicode characters.
    Here are the notes i put in chapter 8 of my book, section 8.2.2
    Notes:
    Pre-10.2 JDBC does not support NCHAR literal (n'...') containing
    Unicode characters that cannot be represented in the database character
    set.
    Using 10.2 JDBC against 10.2 RDBMS, NCHAR literals (n'...')
    are converted to Unicode literals (u'...'); non-ASCII characters
    are converted to their corresponding Unicode escape sequence.
    Using 10.2 JDBC against pre-10.2 RDBMS, NCHAR literals (n'...') are
    not converted and generate undetermined content for characters that
    cannot be represented in the database character set.
    Fwiw, here is my blog entry relative to Lobs (CLOB, BLOB, BFILE) :
    http://db360.blogspot.com/2006/11/get-bolder-with-lobs-manipulation-in.html
    Kuassi, http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html

  • How to insert more than 32k xml data into oracle clob column

    how to insert more than 32k xml data into oracle clob column.
    xml data is coming from java front end
    if we cannot use clob than what are the different options available

    Are you facing any issue with my code?
    String lateral size error will come when you try to insert the full xml in string format.
    public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
      boolean isUpdated = true;
      Connection connection = null;
      try {
      connection = ConnectionManager.getConnection ();
      //connection.setAutoCommit ( false );
      PreparedStatement PREPARE_STATEMENT = null;
      String sqlQuery = "UPDATE " + tableName + " SET " + columnName + "  = ?  WHERE ID =" + id;
      PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
      // converting string to reader stream
      Reader reader = new StringReader ( strContents );
      PREPARE_STATEMENT.setClob ( 1, reader );
      // return false after updating the clob data to DB
      isUpdated = PREPARE_STATEMENT.execute ();
      PREPARE_STATEMENT.close ();
      } catch ( SQLException e ) {
      e.printStackTrace ();
      finally{
      return isUpdated;
    Try this JAVA code.

  • Date Fields...in BC4J??

    hi,
    How can I set default value as SYSDATE in the Date field in View Object- Attribute settings? This should be displayed in JSP.
    How will I specify different formats for Date (dd/mm/yyyy)in JSP created using BC4J ? Another thing is that i have to pass a parameter(date format) and set this format according to the passed parameter. Is there anyway to do this?
    One more problem is if i add any validations to any of the fields thru BC4J-Entity object-Validation Tab ,it will no more accept null values while inserting.Is there anyway by which i can fire the validations only if values are entered to the field and not when the field is null. Note that the field is not mandatory field at all.
    I'm stuck with date here, some pls reply..

    Arun,
    You can set a default date using a before insert database trigger. If you do this, make sure to set the Refresh After Insert checkbox for the date attribute in the Entity Object wizard.
    As for setting the NLS_DATE_FORMAT based on a parameter, one way is to do this from an exported method on the view object. Pass the method the format you want to set, then use JDBC to issue the 'alter session set NLS_DATE_FORMAT' command.
    Laura

  • Inserting data into a Clob

    I need to insert data into a Clob (>8k) and have not been able to determine how
    to do it without using Oracle's extensions to the JDBC JDK.
    Does anyone have a code snippet to show how to populate the Clob in the first
    place?
    Thanks,
    Cully.
    Settings from weblogic.properties:
    weblogic.jdbc.connectionPool.oraclePoolCSA=\
    url=jdbc:oracle:thin:@IHP273:1521:AIRCORE,\
    driver=oracle.jdbc.driver.OracleDriver,\
    loginDelaySecs=1,\
    initialCapacity=1,\
    maxCapacity=2,\
    capacityIncrement=2,\
    allowShrinking=true,\
    shrinkPeriodMins=15,\
    refreshMinutes=10,\
    testTable=dual,\
    props=user=csav2;password=csav2
    weblogic.allow.reserve.weblogic.jdbc.connectionPool.oraclePoolCSA=\
    guest,everyone
    weblogic.allow.reset.weblogic.jdbc.connectionPool.oraclePoolCSA=everyone
    weblogic.allow.shrink.weblogic.jdbc.connectionPool.oraclePoolCSA=everyone
    weblogic.jdbc.TXDataSource.CSATXDataSource=oraclePoolCSA

    Shiva,
    That was it....instead of doing the Blob work all in the same insert
    statement, I grabbed a new sequence and inserted a row with an empty_blob().
    After that I did an update on that row setting the correct value of the
    Blob.
    Thanks for the help!!
    "Shiva Paranandi" <[email protected]> wrote in message
    news:[email protected]...
    I tried with SP2 only and it works. The problems might be that you aregetting a
    null blob. Try inserting an emtpy blob first. Check out this program whichworks
    for me on WLS 6, SP2.
    Shiva.
    Tony Bailey wrote:
    Still getting the NPE. Any other ideas??? Are you able to do this
    successfully on sp2?
    "Shiva Paranandi" <[email protected]> wrote in message
    news:[email protected]...
    Try these two things:
    1. Change your SQL query to "SELECT image FROM " + table + " for
    update";
    2. Also, set conn.setAutoCommit(false);
    Shiva.
    Tony Bailey wrote:
    If I step through the code in the debugger, everything is A-OK up
    until
    the
    getBinaryOutputStream, then I get a NPE. The blob appears to be
    instantiated when I toString() it in the previous line.
    private Blob getBlob(File f, String table)
    throws SQLException
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String SQL;
    Blob imgblob = null;
    FileInputStream fis = null;
    OutputStream bos = null;
    try
    conn = dbutil.getConnection();
    SQL = "SELECT image FROM " + table;
    pstmt = conn.prepareStatement(SQL);
    rs = pstmt.executeQuery();
    rs.next();
    imgblob = rs.getBlob("image");
    logger.log(Debug.DEBUG, "DictTblCtrlr.getBlob(): The
    blob
    is: "
    + imgblob);
    fis = new FileInputStream(f);
    bos = ((OracleBlob)imgblob).getBinaryOutputStream();
    byte[] buffer = new byte[65534];
    int length = -1;
    while ((length = fis.read(buffer)) != -1)
    bos.write(buffer, 0, length);
    bos.flush();
    catch (Exception sqle)
    logger.log(Debug.ERROR, "DictTblCtrlr.getBlob(): " +
    sqle.getMessage());
    sqle.printStackTrace();
    throw new SQLException(sqle.getMessage());
    finally
    try { fis.close();  bos.close(); } catch (Exception e)
    dbutil.release(rs, pstmt, conn);
    return imgblob;
    [07-19-2001 03:02:07] DEBUG:DictTblCtrlr.getBlob(): The blob is:
    weblogic.jdbc.rmi.SerialBlob@1f1f12
    [07-19-2001 03:02:23] ERROR:DictTblCtrlr.getBlob():
    java.lang.NullPointerException
    java.sql.SQLException: java.lang.NullPointerException
    at
    weblogic.jdbc.rmi.SerialBlob.getBinaryOutputStream(SerialBlob.java:73)
    at
    com.uctech.psws.persistence.datacontroller.DictionaryTableController.getBlob
    (DictionaryTableController.java:410)
    at
    com.uctech.psws.persistence.datacontroller.DictionaryTableController.insert(
    DictionaryTableController.java:363)
    "Shiva Paranandi" <[email protected]> wrote in message
    news:[email protected]...
    Could you post the exception?
    Shiva.
    Tony Bailey wrote:
    Using the example, I get a NullPointerException when calling
    getBinaryOutputStream() under WL6.0sp2.
    "Filip Hanik" <[email protected]> wrote in message
    news:[email protected]...
    look under
    $BEA_HOME/wlserver6.0sp1/samples/examples/jdbc/oracle/OracleBlobClob.java
    >>>>>>>
    ~
    Namaste - I bow to the divine in you
    ~
    Filip Hanik
    Software Architect
    [email protected]
    www.filip.net
    "Cully Orstad" <[email protected]> wrote in message
    news:[email protected]...
    I need to insert data into a Clob (>8k) and have not been
    able
    to
    determine how
    to do it without using Oracle's extensions to the JDBC JDK.
    Does anyone have a code snippet to show how to populate the
    Clob
    in
    the
    first
    place?
    Thanks,
    Cully.
    Settings from weblogic.properties:
    weblogic.jdbc.connectionPool.oraclePoolCSA=\
    url=jdbc:oracle:thin:@IHP273:1521:AIRCORE,\
    driver=oracle.jdbc.driver.OracleDriver,\
    loginDelaySecs=1,\
    initialCapacity=1,\
    maxCapacity=2,\
    capacityIncrement=2,\
    allowShrinking=true,\
    shrinkPeriodMins=15,\
    refreshMinutes=10,\
    testTable=dual,\
    props=user=csav2;password=csav2
    weblogic.allow.reserve.weblogic.jdbc.connectionPool.oraclePoolCSA=\
    guest,everyone
    weblogic.allow.reset.weblogic.jdbc.connectionPool.oraclePoolCSA=everyone
    >>>>>>>>
    >>>>>>
    >>>>
    >>
    weblogic.allow.shrink.weblogic.jdbc.connectionPool.oraclePoolCSA=everyone
    >>>>>>>>
    weblogic.jdbc.TXDataSource.CSATXDataSource=oraclePoolCSA

Maybe you are looking for