APEX and CLOB value in trigger

Hi,
I am using APEX 3.2.1 with Oracle 11gR1.
I have two tables:
CREATE TABLE "TSI"."ATT_TEST2"
(     "ID" NUMBER NOT NULL ENABLE,
     "TITLE" VARCHAR2(250 BYTE),
     "TOPIC" CLOB
and
CREATE TABLE "TSI"."ATT_TEST2"
(     "ID" NUMBER NOT NULL ENABLE,
     "TITLE" VARCHAR2(250 BYTE),
     "TOPIC" CLOB
My trigger is:
create or replace TRIGGER "TSI"."ATT_TEST_TRG"
BEFORE INSERT ON ATT_TEST
FOR EACH ROW
BEGIN
SELECT ATT_TEST_SEQ.NEXTVAL INTO :new.ID FROM DUAL;
insert into att_test2(id, title, topic) values (ATT_TEST_SEQ.NEXTVAL, :new.title, :new.topic);
END;
Now if I insert a record to ATT_TEST using SQL Developer ATT_TEST2 gets populated.
If create an APEX form and try to insert into ATT_TEST i get all the fields inserted into ATT_TEST2 except for the CLOB column. The TOPIC column is not copied into ATT_TEST2.
Any idea why this works from SQL Developer and not from APEX?
Thank you

Hello:
I believe this behaviour is seen because APEX uses the 'DBMS_LOB' API to update LOB/CLOB columns.For the example posted APEX does something like
INSERT INTO "ATT_TEST" ( "ID","TITLE","TOPIC") VALUES (:B1 ,REPLACE(:B2 ,'%null%',NULL),EMPTY_CLOB()) RETURNING ROWID INTO :0;
begin select "TOPIC" into wwv_flow.g_dml_clob_text from "ATT_TEST" where rowid = :p_rowid for update; end;
begin dbms_lob.write( wwv_flow.g_dml_clob_text, length(wwv_flow.g_dml_varchar32767_text), 1, wwv_flow.g_dml_varchar32767_text ); end;
varad

Similar Messages

  • Trigger how to get new and old value for nested table column?

    Hi,
    I have created a nested table based on the following details:
    CREATE TYPE typ_item AS OBJECT --create object
    (prodid NUMBER(5),
    price NUMBER(7,2) )
    CREATE TYPE typ_item_nst -- define nested table type
    AS TABLE OF typ_item
    CREATE TABLE pOrder ( -- create database table
    ordid NUMBER(5),
    supplier NUMBER(5),
    requester NUMBER(4),
    ordered DATE,
    items typ_item_nst)
    NESTED TABLE items STORE AS item_stor_tab
    INSERT INTO pOrder
    VALUES (800, 80, 8000, sysdate,
    typ_item_nst (typ_item (88, 888)));
    Now I would like to create a trigger on table pOrder for after insert or update or delete
    and I would like to track the new and old value for the columns inside nested table.
    Can anybody direct me how to do it?
    I would like to know the sytax for it like:
    declare
    x number;
    begin
    x := :new.nestedtablecolumn;--how to get the new and old value from nested table columns
    end;
    Hope my question is clear.
    Thanks,
    Lavan

    Hi,
    Try like this:
    CREATE OR REPLACE TRIGGER PORDER_I
    BEFORE INSERT
    ON PORDER
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    DECLARE
      items_new typ_item_nst;
      ordid_NEW NUMBER;
    BEGIN
    FOR i IN :new.items.FIRST .. :new.items.LAST LOOP -- For first to last element
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').prodid: ' || :new.items(I).prodid );
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').price:  ' || :new.items(I).price );
    END LOOP;
    END;Regards,
    Peter

  • How to create and send clob value to SP?

    Hi,
    Does any one of an example of how to create and send
    a clob value(as a IN parameter to storedprocedure) from JAVA to
    the StoredProcedure. I need the JAVA code.
    null

    Hi 
    Following is sample code you can use.
    DECLARE @testID Int
    DECLARE @year int 
    DECLARE @testtype datatype
    SELECT @testtype=testtype from yourTable Where Your condition
    SELECT  @year= year from yourTable Where your conditon (you need to make sure you assign or get @year variable )
    SELECT @testid=id from test where  year=@year and testtype=@testtype)
    Hope this helps
    Regards

  • Capture Web Cam image in APEX and Upload into the Database

    Overview
    By using a flash object, you should be able to interface with a usb web cam connected to the client machine. Their are a couple of open source ones that I know about, but the one I chose to go with is by Taboca Labs and is called CamCanvas. This is released under the MIT license, and it is at version 0.2, so not very mature - but in saying that it seems to do the trick. The next part is to upload a snapshot into the database - in this particular implementation, it is achieved by taking a snapshot, and putting that data into the canvas object. This is a new HTML5 element, so I am not certain what the IE support would be like. Once you have the image into the canvas, you can then use the provided function convertToDataURL() to convert the image into a Base64 encoded string, which you can then use to convert into to a BLOB. There is however one problem with the Base64 string - APEX has a limitation of 32k for and item value, so can't be submitted by normal means, and a workaround (AJAX) has to be implemented.
    Part 1. Capturing the Image from the Flash Object into the Canvas element
    Set up the Page
    Required Files
    Download the tarball of the webcam library from: https://github.com/taboca/CamCanvas-API-/tarball/master
    Upload the necessary components to your application. (The flash swf file can be got from one of the samples in the Samples folder. In the root of the tarball, there is actually a swf file, but this seems to be a different file than of what is in the samples - so I just stick with the one from the samples)
    Page Body
    Create a HTML region, and add the following:
        <div class="container">
           <object  id="iembedflash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="240">
                <param name="movie" value="#APP_IMAGES#camcanvas.swf" />
                <param name="quality" value="high" />
              <param name="allowScriptAccess" value="always" />
                <embed  allowScriptAccess="always"  id="embedflash" src="#APP_IMAGES#camcanvas.swf" quality="high" width="320" height="240"
    type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" mayscript="true"  />
        </object>
        </div>
    <p><a href="javascript:captureToCanvas()">Capture</a></p>
    <canvas style="border:1px solid yellow"  id="canvas" width="320" height="240"></canvas>That will create the webcam container, and an empty canvas element for the captured image to go into.
    Also, have a hidden unprotected page item to store the Base64 code into - I called mine P2_IMAGE_BASE64
    HTML Header and Body Attribute
    Add the Page HTML Body Attribute as:
    onload="init(320,240)"
    JavaScript
    Add the following in the Function and Global Variable Declarations for the page (mostly taken out of the samples provided)
    //Camera relations functions
    var gCtx = null;
    var gCanvas = null;
    var imageData = null;
    var ii=0;
    var jj=0;
    var c=0;
    function init(ww,hh){
         gCanvas = document.getElementById("canvas");
         var w = ww;
         var h = hh;
         gCanvas.style.width = w + "px";
         gCanvas.style.height = h + "px";
         gCanvas.width = w;
         gCanvas.height = h;
         gCtx = gCanvas.getContext("2d");
         gCtx.clearRect(0, 0, w, h);
         imageData = gCtx.getImageData( 0,0,320,240);
    function passLine(stringPixels) {
         //a = (intVal >> 24) & 0xff;
         var coll = stringPixels.split("-");
         for(var i=0;i<320;i++) {
              var intVal = parseInt(coll);
              r = (intVal >> 16) & 0xff;
              g = (intVal >> 8) & 0xff;
              b = (intVal ) & 0xff;
              imageData.data[c+0]=r;
              imageData.data[c+1]=g;
              imageData.data[c+2]=b;
              imageData.data[c+3]=255;
              c+=4;
         if(c>=320*240*4) {
              c=0;
              gCtx.putImageData(imageData, 0,0);
    function captureToCanvas() {
         flash = document.getElementById("embedflash");
         flash.ccCapture();
         var canvEle = document.getElementById('canvas');
         $s('P2_IMAGE_BASE64', canvEle.toDataURL());//Assumes hidden item name is P2_IMAGE_BASE64
         clob_Submit();//this is a part of part (AJAX submit value to a collection) two
    }In the footer region of the page (which is just a loading image to show whilst the data is being submitted to the collection [hidden by default]) :<img src="#IMAGE_PREFIX#processing3.gif" id="AjaxLoading"
    style="display:none;position:absolute;left:45%;top:45%;padding:10px;border:2px solid black;background:#FFF;" />If you give it a quick test, you should be able to see the webcam feed and capture it into the canvas element by clicking the capture link, in between the two elements - it might through a JS error since the clob_Submit() function does not exist yet.
    *Part 2. Upload the image into the Database*
    As mentioned in the overview, the main limitation is that APEX can't submit values larger than 32k, which I hope the APEX development team will be fixing this limitation in a future release, the workaround isn't really good from a maintainability perspective.
    In the sample applications, there is one that demonstrates saving values to the database that are over 32k, which uses an AJAX technique: see http://www.oracle.com/technetwork/developer-tools/apex/application-express/packaged-apps-090453.html#LARGE.
    *Required Files*
    From the sample application, there is a script you need to upload, and reference in your page. So you can either install the sample application I linked to, or grab the script from the demonstration I have provided - its called apex_save_large.js.
    *Create a New Page*
    Create a page to Post the large value to (I created mine as 1000), and create the following process, with the condition that Request = SAVE. (All this is in the sample application for saving large values).declare
         l_code clob := empty_clob;
    begin
         dbms_lob.createtemporary( l_code, false, dbms_lob.SESSION );
         for i in 1..wwv_flow.g_f01.count loop
              dbms_lob.writeappend(l_code,length(wwv_flow.g_f01(i)),wwv_flow.g_f01(i));
         end loop;
         apex_collection.create_or_truncate_collection(p_collection_name => wc_pkg_globals.g_base64_collection);
         apex_collection.add_member(p_collection_name => wc_pkg_globals.g_base64_collection,p_clob001 => l_code);
         htmldb_application.g_unrecoverable_error := TRUE;
    end;I also created a package for storing the collection name, which is referred to in the process, for the collection name:create or replace
    package
    wc_pkg_globals
    as
    g_base64_collection constant varchar2(40) := 'BASE64_IMAGE';
    end wc_pkg_globals;That is all that needs to be done for page 1000. You don't use this for anything else, *so go back to edit the camera page*.
    *Modify the Function and Global Variable Declarations* (to be able to submit large values.)
    The below again assumes the item that you want to submit has an item name of 'P2_IMAGE_BASE64', the condition of the process on the POST page is request = SAVE, and the post page is page 1000. This has been taken srtaight from the sample application for saving large values.//32K Limit workaround functions
    function clob_Submit(){
              $x_Show('AjaxLoading')
              $a_PostClob('P2_IMAGE_BASE64','SAVE','1000',clob_SubmitReturn);
    function clob_SubmitReturn(){
              if(p.readyState == 4){
                             $x_Hide('AjaxLoading');
                             $x('P2_IMAGE_BASE64').value = '';
              }else{return false;}
    function doSubmit(r){
    $x('P2_IMAGE_BASE64').value = ''
         flowSelectAll();
         document.wwv_flow.p_request.value = r;
         document.wwv_flow.submit();
    }Also, reference the script that the above code makes use of, in the page header<script type="text/javascript" src="#WORKSPACE_IMAGES#apex_save_large.js"></script>Assuming the script is located in workspace images, and not associated to a specific app. Other wise reference #APP_IMAGES#
    *Set up the table to store the images*CREATE TABLE "WC_SNAPSHOT"
    "WC_SNAPSHOT_ID" NUMBER NOT NULL ENABLE,
    "BINARY" BLOB,
    CONSTRAINT "WC_SNAPSHOT_PK" PRIMARY KEY ("WC_SNAPSHOT_ID")
    create sequence seq_wc_snapshot start with 1 increment by 1;
    CREATE OR REPLACE TRIGGER "BI_WC_SNAPSHOT" BEFORE
    INSERT ON WC_SNAPSHOT FOR EACH ROW BEGIN
    SELECT seq_wc_snapshot.nextval INTO :NEW.wc_snapshot_id FROM dual;
    END;
    Then finally, create a page process to save the image:declare
    v_image_input CLOB;
    v_image_output BLOB;
    v_buffer NUMBER := 64;
    v_start_index NUMBER := 1;
    v_raw_temp raw(64);
    begin
    --discard the bit of the string we dont need
    select substr(clob001, instr(clob001, ',')+1, length(clob001)) into v_image_input
    from apex_collections
    where collection_name = wc_pkg_globals.g_base64_collection;
    dbms_lob.createtemporary(v_image_output, true);
    for i in 1..ceil(dbms_lob.getlength(v_image_input)/v_buffer) loop
    v_raw_temp := utl_encode.base64_decode(utl_raw.cast_to_raw(dbms_lob.substr(v_image_input, v_buffer, v_start_index)));
    dbms_lob.writeappend(v_image_output, utl_raw.length(v_raw_temp),v_raw_temp);
    v_start_index := v_start_index + v_buffer;
    end loop;
    insert into WC_SNAPSHOT (binary) values (v_image_output); commit;
    end;Create a save button - add some sort of validation to make sure the hidden item has a value (i.e. image has been captured). Make the above conditional for request = button name so it only runs when you click Save (you probably want to disable this button until the data has been completely submitted to the collection - I haven't done this in the demonstration).
    Voila, you should have now be able to capture the image from a webcam. Take a look at the samples from the CamCanvas API for extra effects if you wanted to do something special.
    And of course, all the above assumed you want a resolution of 320 x 240 for the image.
    Disclaimer: At time of writing, this worked with a logitech something or rather webcam, and is completely untested on IE.
    Check out a demo: http://apex.oracle.com/pls/apex/f?p=trents_demos:webcam_i (my image is a bit blocky, but i think its just my webcam. I've seen others that are much more crisp using this) Also, just be sure to wait for the progress bar to dissappear before clicking Save.
    Feedback welcomed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hmm, maybe for some reason you aren't getting the base64 version of the saved image? Is the collection getting the full base64 string? Seems like its not getting any if its no data found.
    The javascript console is your friend.
    Also, in the example i used an extra page, from what one of the examples on apex packages apps had. But since then, I found this post by Carl: http://carlback.blogspot.com/2008/04/new-stuff-4-over-head-with-clob.html - I would use this technique for submitting the clob, over what I have done - as its less hacky. Just sayin.

  • 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();
    }

  • Issue with Apex and IE , losing data for items on submit

    Hi All,
    I am facing one problem in APEX when i run my page on IE 8. When i submit the page i lose the data for all my items while the same does not happen on Firefox mozila and Google chorme.
    Actually i have one select list which has one dynamic action associated with it when i select the options from this list other object become enable and disable with that action and page get submit.
    but when i select this list in IE page get submit and my value which i selected also get lost.
    Please let me know if this is some issue with IE or Apex as soon as possible.
    This is bit urgent.
    Thanks

    Modify your code as below and run the page in debug mode and note the value shown for p610_x DECLARE
    l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
    BEGIN
    wwv_flow.debug('value for p610_x is ' || :p610_x);
    l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(:P610_X,'~');
    FOR z IN 1..l_vc_arr2.count LOOP
    htp.p(l_vc_arr2(z) || '
    END LOOP;
    END;varad

  • $200 reward to solve problem with JDBC and CLOB.getCharacterOutputStream

    I'm trying to update CLOB with the getCharacterOutputStream as suggested in the example code. It works with US7ASCII DB instance but not instances in UTF8.
    I've been browsing through all the Oracle doc's and found some rather confusing statements:
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oralob2.htm#1043220
    it says: [When writing to or reading from a CLOB, the JDBC drivers perform all character set conversions for you.]
    also: [The oracle.sql.CLOB class supports all the character sets that the Oracle data server supports for CLOB types.]
    So far so good.
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oraint3.htm#1012518
    it says [The oracle.sql package supports these datatypes in several ways: CLOBs point to large fixed-width character data items (that is, characters that require a fixed number of bytes per character) and are supported by the oracle.sql.CLOB class.]
    Ooh no! Is this for real? UTF8 is variable width and does this mean it is not supported?
    Any way to get around this?
    In the page at http://oradoc.photo.net/ora816/java.816/a81358/03_pub2.htm#36009
    says [6.The mappings to oracle.sql classes are optimal because they preserve data formats and require no character-set conversions (apart from the usual network conversions). Those classes are especially useful in applications that "shovel" data between SQL and Java.]
    "No character set conversion"? Very confusing!
    I've been hammering on this CLOB/JDBC/UTF8 problem for more than a week now and I really appreciate some solutions, workarounds, or whatever help I can get. I'm running java stored procedure in 8.1.6 on Linux RH6.2.
    For your trouble, I'd pay $200 for the first guy who come up with a verifiable solution.

    This is just findings based upon your comments:
    Please refer to document Oracle8i National Language Support Guide
    Release 2 (8.1.6) from Oracle Documentation Library, Release 8.1.7
    Chapter 6 Java,
    There its clearly mention that:
    "Oracle JDBC drivers provide globalization support by allowing users to retrieve data from or insert data into a database in any character set that Oracle supports. Because Java strings are UCS2 encoded (16-bit Unicode) for JDBC programs, the target character set on the client is always UCS2. Character set conversion is required to convert data from the database character set (Db Charset) to UCS2. This applies to CHAR, LONG, CLOB, and VARCHAR2 data types; RAW data is not converted. "
    Also..please refer this...
    "oracle.sql.CLOB's method getCharacterStream() returns the contents of a CLOB as a Unicode stream."
    "The techniques that Oracle's drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses a US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UCS2,which is used in Java applications. "
    "If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, Japanese or Korean), then the driver converts the data, first to UTF8, then to UCS2. "
    In my case the characte-set of the database is WE8ISO8859P1 and for security reason i can't change the character set but my feeling is that if you are updating the CLob from the java client you are forming a reference of a clob in the client which is UCS2 at the Java side. Now when you are populating the clob through java.io.Writer and call the procedure to pass the reference of the clob to the procedure then I believe the JDBC will convert the UCS2 datatype of Clob to UTF8 in the database.
    You can try out the code snippet:
    package ServletGDC;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import ClassesGDC.*;
    public class testUpload extends HttpServlet {
    private String m_strMessage="";//It stores the message to be uploaded along with the Document
    Connection conn=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    String strContent="";
    //res.setContentType("application/msword");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try {
    CallableStatement cmt=null;
    OutputStream output=null;
    ByteArrayOutputStream byteoutput=null;
    String strDocString="";
    oracle.sql.CLOB tempClob = null;
    String strPassedFileName="";     // the file name passed in the request object
    String strStdFilename="";//the file name to be given to the best practice
    String strSaveDirectory="";     //the directory in which the bp is to be saved
    String strParamName="";//name of parameters
    String strParamValue="";//value of parameters
    int intTempVariable=0; // temporaty variable
    long lngSizeOfFileUploaded=0;//stores the size of the file which had been uploaded in the file system
    File filePathOfFileUploaded=null;//stores the path of the file uploaded to the file system
    String strQuery="";
    //ST------------checks if the user has logged in or not-----------------------
    HttpSession session=req.getSession(true);
    if(req.getContentLength()>20*1024*1024)
    throw new skip("The size of the posted content is more than 10 MB . If you have a best practice whose size is more than 1 MB please mail it to Us.");
    byteoutput = new ByteArrayOutputStream();
    MultipartParser mp = new MultipartParser(req, 20*1024*1024); // 10MB is the limit of the file to be uploaded
    Part part;//Its an abstact part which helps in retrieving information about the file and the parameters
    while ((part = mp.readNextPart()) != null) {//Reads the next part
    strParamName = part.getName();
    // the following if is executed if the part is for a parameter rather than a file
    if (part.isParam()) {
    }else if (part.isFile()) {
    // it's a file part
    m_strMessage="inside file part";
    FilePart filePart = (FilePart) part;
    strPassedFileName = filePart.getFileName();
    strContent= filePart.getContentType();
    out.println("<BR><font color=red>strPassedFileName is "+strPassedFileName+"</font>");
    if(strPassedFileName != null || !(strPassedFileName.trim().equals("")) ) {
    // the part actually contained a file
    out.println("<BR><font color=red> before forming long</font>");
    //lngSizeOfFileUploaded = filePart.writeTo(filePathOfFileUploaded);      //the statement upload the bestpractice in the
    lngSizeOfFileUploaded = filePart.writeTo(byteoutput);     //specified file path filePathOfFileUploaded.
    out.println("<BR><font color=red> after file is written into the outputstream</font>");
    else {
    throw new skip("The file name is null or it is empty space. Files in such Format are not accepted");
    }//end of else if
    }//end of while loop
    if(     lngSizeOfFileUploaded==0)     {// the size of the file uploaded is zero then the file supplied was not proper and hence exception is to be thrown
    //if(filePathOfFileUploaded.exists())
    //     filePathOfFileUploaded.delete();
    throw new skip("The File could not be uploaded,Possible reasons may be that the file is sent null or the file is corrupted");
    //END---------------the file is uploaded in the proper directory--------------------
    //res.setContentType(strContent);
    out.println("<BR><font color=red>long value is : "+lngSizeOfFileUploaded+" and content is "+strContent+"</font>");
    String strbyte= byteoutput.toString();
    byteoutput.flush();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Establish network connection to database
    conn = DriverManager.getConnection("jdbc:oracle:thin:@pc-p32670:1521:GDCDBI","gdc_user","myuser");
    //if(conn!=null)
    out.println("<BR><font color=red>Connection formed"+conn);
    //els
    //out.println("<BR><font color=red>long value is : "+strbyte+"</font>");
    try{
    tempClob = oracle.sql.CLOB.createTemporary(conn,true, oracle.sql.CLOB.DURATION_SESSION);
    out.println("<BR><font color=red>tempClob : "+tempClob);
    tempClob.open( oracle.sql.CLOB.MODE_READWRITE);
    java.io.Writer tempClobWriter = tempClob.getCharacterOutputStream();
    // writing the string formed from the multipart file to the clob
    tempClobWriter.write(strbyte);
    if(tempClob!=null){}
    out.println("<BR><font color=red>CLOB value is : "+tempClob+"</font>");
    strQuery="{call INSERT_CLOB(?,?)}";
    cmt=conn.prepareCall(strQuery);
    cmt.setString(1,strPassedFileName);
    cmt.setClob(2,tempClob);
    cmt.registerOutParameter(2,java.sql.Types.CLOB);
    cmt.execute();
    tempClobWriter.flush();
    tempClobWriter.close();
    tempClob.freeTemporary();
    //res.setContentType(strContent);
    //strDocString.toString();
    out.println("<BR><font color=red>bob is "+strbyte+"</font>");
    tempClob.close();
    }catch(Exception e){
    tempClob.close();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    cmt.close();
    //out.println("<BR><font color=red><h2><b>SUCCESS</h2></font>");
    //res.sendRedirect("../test/showfile.jsp?contentype="+strContent.trim()+"");
    }catch(Exception e){
    java.util.Date d = new java.util.Date();
    String s =d.toString();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    }finally{
    try{
    if(conn!=null)
    conn.close();
    }catch(Exception e){
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    }// end of finally
    } //end of doPost
    } //end of class
    in the Procedure you will be inserting/updating the clob in a table with the reference clob in the out parameter of the procedure
    Thanks.

  • APEX and iText PDF generation

    Hi,
    Has any one used iText in apex to generate PDF documents in APEX. The reason for me to look for a solution to generate PDF documents like invoice, Purchase Order for different customer in different format. Since the online hosting companies have different reporting services like (JasperReport/Oracle BI publisher etc) it is a pain full procedure to have rtf and XML-FO. If I use iText within the PL/SQL procedure which will generate PDF document by supplying PDF form and XML data.
    In this case the client can create there PDF form which can be filled by XML data.
    Thank you.

    I had a look but seems like I have use command line to execute the process. You do.
    I want to generate from PL/SQL. My package does. Mind you -- I have to make use of a host command to perform the actual integration. When a process 'prints' to a PDF, it supplies the PDF form to be filled in, the specific fields to be filled in, and the values for the fields. I write these values out to an FDF file for the appropriate PDF form on the OS, then call PDFTK via a host command to integrate the blank PDF and the newly-created FDF into a 'filled' PDF form. I then email the completed PDF file to the user that requested it.

  • SQL Query (updateable report) Region - Conditionally Hide and Set Values

    SQL Query (updateable report) Region - Conditionally Hide and Set Values
    Outline of requirement :-
    Master / Detail page with Detail updated on same page using SQL Query (updateable report).
    The detail region has the following source
    SELECT item_id,
           contract_id,
           CASE WHEN hardware_id IS NOT NULL THEN
                   'HA'
                WHEN backup_dev_id IS NOT NULL THEN
                   'BD'
                WHEN hardware_os_id IS NOT NULL THEN
                   'HS'
           END item_type,
           hardware_id,
           backup_dev_id,
           hardware_os_id
    FROM   "#OWNER#".support_items
    WHERE  contract_id = :P26_CONTRACT_IDThe table support_items implements arced relationships and has the following columns
    CREATE TABLE SUPPORT_ITEMS
      ITEM_ID         NUMBER                        NOT NULL,
      CONTRACT_ID     NUMBER                        NOT NULL,
      HARDWARE_ID     NUMBER,
      BACKUP_DEV_ID   NUMBER,
      HARDWARE_OS_ID  NUMBER
    )A check type constaint on support_items ensures that only one of the fk's is present.
          (    hardware_id    IS NOT NULL
           AND backup_dev_id  IS NULL
           AND hardware_os_id IS NULL
    OR    (    hardware_id    IS NULL
           AND backup_dev_id  IS NOT NULL
           AND hardware_os_id IS NULL
    OR    (    hardware_id    IS NULL
           AND backup_dev_id  IS NULL
           AND hardware_os_id IS NOT NULL
          )    Hardware_Id is a FK to Hardware_Assets
    Backup_dev_id is a FK to Backup_Devices
    Hardware_os_id is a FK to Hardware_op_systems
    The Tabular Form Element based on item_type column of SQL query is Displayed As Select List (based on LOV) referencing a named list of values which have the following properties
    Display Value     Return Value
    Hardware Asset    HA
    Backup Device     BD
    Computer System   HSThe Tabular Form Elements for the report attributes for hardware_id, backup_dev_id and hardware_os_id are all Displayed As Select List (Based on LOV).
    What I want to do is only display the Select List for the FK depending on the value of the Select List on Item Type, e.g.
    Item_Type is 'HA' then display Select List for hardware_id, do not display and set to NULL the Select Lists for backup_dev_id and hardware_os_id.
    Item_Type is 'BB' then display Select List for backup_dev_id, do not display and set to NULL the Select Lists for hardware_id and hardware_os_id.
    Item_Type is 'HS' then display Select List for hardware_os_id, do not display and set to NULL the Select Lists backup_dev_id and hardware_id.
    There are properties on elements to conditionally display it but how do we reference the values of the SQL query Updateable region? they are not given a page item name?
    Also on the Tabular For Elements there is an Edit tick against a report item - however when you go to the Column Attributes there is not a property with which you can control the Edit setting.
    What's the best way of implementing this requirement in APEX 3.1?
    Thanks.

    >
    Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your profile with a real handle instead of "user13515136".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I have a multi-row region that displays values and allows entries in a number of fields.Provide exact details of how this has been implemented. (An example on apex.oracle.com is always a good way to do this.)
    I should like the fields to be conditional in that they do not permit entry, but still display, if certain conditions apply (e.g. older rows greyed out). Can this be done? Almost anything can be done, often in multiple ways. Which are appropriate may be dependent on a particular implementation, the skills available to implement it, and the effort you're willing to expend on it. Hence it's necessary to provide full details of what you've done so far...

  • PO and iV value diff

    Dear friends,
    I need to know
    where we are defining the tol between gr value and IV value.
    Assume PO value is 1000 and IV is 1050
    how the system will accept this?
    Is it possible to make this for all vendor or individually ?
    pl reply
    guru

    Hi,
    If The Material is maintained with MAV then Material Account will Trigger..
    and if the Material is having Standarad price then Price diff Account will trigger (PRD)
    If it is Standard price..
    Account
    K
    Vendor --- -
    1050 INR
    S -
    Goods Rcvd/Invoice Rcvd -
    1000 INR
    S -
    Income from price differences of own goods ---50 INR
    If The Price is MAV
    Account
    K
    Vendor --- -
    1050 INR
    S -
    Goods Rcvd/Invoice Rcvd -
    1000 INR
    M -
    Material Deasription ---50 INR
    Thx
    Raju

  • How to put the column name and variable value in the alert message.

    Dear,
    how can i put the column name and variable value in the alert message text. i want to display an alert which tell the user about the empty textboxes. that these textboxes must be filled.
    Regards:
    Muhammad Nadeem
    CHIMERA PVT. LTD.
    LAHORE
    [email protected]

    Hello,
    The name of the item that fires the current trigger is stored in the :SYSTEM.TRIGGER_ITEM system variable.
    The value contained in this item can be retrived with the Name_In() built-in
    value := Name_In( 'SYSTEM.TRIGGER_ITEM') ;
    LC$Msg := 'The item ' || :SYSTEM.TRIGGER_ITEM || ' must be entered' ;
    Set_Alert_Property('my_alert_box', ALERT_MESSAGE_TEXT, LC$Msg ) ;
    Ok := Show_Alert( 'my_alert_box' ) ;
    ...Francois

  • How do you audit a clob from a trigger

    I've manged to get the :OLD.clob_value to be audited but I cannot audit a :NEW.clob_value in an update or insert trigger. I even created a before insert for each row trigger and an after statement trigger then try to simply select the clob_value into the audit table and this does not work either.
    Has anyone ever had to audit a CLOB in a trigger?
    Thanks.

    According to Oracle's Support website "Metalink.com" see link below, You cannot access :new.clob in a trigger if your using Oracle 8i. They supposedly fixed this bug in oracle 9.0.2.
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_id=1226565&p_database_id=BUG
    Has anyone found a work around for Oracle 8i?

  • How to set a clob value to a hidden field

    I have a function returning a clob value . Please let me know if there is a way to set a hidden variable with a clob value.

    Hi,
    This functionality is known to be very important and is a key part of the next major release of the JRC planned for the first half of 2008.
    Regards,
    <p>Blair Wheadon</p>
    <p>Product Manager, Crystal Reports</p>

  • XSQL and Clobs

    I have run into some trouble with retrieving Clob fields with XSQL, seems as though the resultset I am getting is a pointer to the data and not the data itself.
    This is what I am trying to do.
    1. Query an Oracle 8i data base that contains multiple clob fields in which the data has been Base64 encoded (using ColdFusion).
    2. Loop over the Query for the designated Clob fields and decode them using BASE64Decoder() from the sun.misc library.
    3. Create a new XML node with the decoded clob value (which would be a WDDX structure).
    I have used the <xsql:query > and that returns the clob field (still base64 encoded) just fine. Should I change my thinking and look for the XML node and Decode that value and create a new node from that. ????
    Hear is a copy of my code. Any Help would be appreciated.
    // Copyright (c) 2000 prosavvy
    package xsql.myclasses;
    * A Class class.
    * <P>
    * @author gwilliams
    import oracle.xml.xsql.*;
    import org.w3c.dom.*;
    import java.sql.*;
    import java.lang.String;
    import java.lang.Object.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.OracleResultSet;
    import java.io.*;
    import sun.misc.BASE64Decoder;
    public class decodetest extends XSQLActionHandlerImpl {
    public void handleAction( Node rootNode ) throws SQLException {
    ResultSet rs = null;
    Statement s = null;
    String stmt = "select sessiondata from persons where personid = 169158";
    if (!requiredConnectionProvided(rootNode)) {
    return;
    try {
    s = getPageRequest().getJDBCConnection().createStatement();
    rs = s.executeQuery(stmt);
    String curDate="";
    String wddx = new String();
    if (rs.next()) {
    // System.out.println(rs.getClob(1));
    curDate = rs.getClob(1).toString();
    BASE64Decoder decoder = new BASE64Decoder();
    wddx = new String(decoder.decodeBuffer(curDate));
    System.out.println(wddx);
    addResultElement(rootNode,"Date",wddx);
    rs.close();
    s.close();
    catch (IOException exs) {
    this.reportErrorIncludingStatement(rootNode,stmt,exs.getMessage());
    rs.close();
    s.close();
    null

    Greg. Your suspicion is correct. The CLOB is just a CLOB "locator" that you select. You need to call the getCharacterStream method to retrieve the stream of contents.
    Here's a modified version of your action handler that appears to work for me.
    import oracle.xml.xsql.*;
    import org.w3c.dom.*;
    import java.sql.*;
    import java.lang.String;
    import java.lang.Object.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.OracleResultSet;
    import java.io.*;
    import sun.misc.BASE64Decoder;
    public class DecodeCLOB extends XSQLActionHandlerImpl {
    public void handleAction( Node rootNode ) throws SQLException {
    ResultSet rs = null;
    Statement s = null;
    String stmt = "select sessiondata from persons where personid = 1";
    if (!requiredConnectionProvided(rootNode)) {
    return;
    try {
    s = getPageRequest().getJDBCConnection().createStatement();
    rs = s.executeQuery(stmt);
    String curDate="";
    String wddx = new String();
    if (rs.next()) {
    // System.out.println(rs.getClob(1));
    Reader r = rs.getClob(1).getCharacterStream();
    StringBuffer sb = new StringBuffer();
    char[] buf = new char[256];
    int charsRead = -1;
    while ( (charsRead = r.read(buf)) != -1 ) {
    sb.append(buf,0,charsRead);
    curDate = sb.toString();
    BASE64Decoder decoder = new BASE64Decoder();
    wddx = new String(decoder.decodeBuffer(curDate));
    System.out.println(wddx);
    addResultElement(rootNode,"Date",wddx);
    rs.close();
    s.close();
    catch (IOException exs) {
    reportErrorIncludingStatement(rootNode,stmt,exs.getMessage());
    rs.close();
    s.close();
    }

  • Model of how APEX handles data (values)?

    Reference {thread:id=2486655}
    I'm trying to get a model of how APEX handles data (values). There are several places(?) that data (values) can exist. Or so it seems. I'm trying to understand how these work -- to put all the pieces together.
    Question:
    A) Where data can be?
    1) In the database
    2) In the session
    3) Rendered -- and hence displayed on the screen, if a displayed value -- but not in the session
    4) In perhaps(?) some working memory pool(?) but different from the page rendered values I see on the screen?
    5) Other?
    Why do I think this is relevant?
    Question:
    B) If there are rendered values and session values different from the rendered values, then when code executes, which of these values (rendered or session) is it executing against?
    And maybe the answer is, "You don't understand what's going on." Yes, "Exactly!" Hence the question.
    Best wishes,
    Howard

    Howard (DBA in Training) wrote:
    I'm putting this together now. For example:
    I set the value of a Page Item (say, :P2_DATA) to "BEFORE" in a Before Region process and change it to "AFTER" in an After Region Process. 'BEFORE' was displayed on the screen but 'AFTER' was in the session state. So I see that PL/SQL changes these values in the session state. But it doesn't "go back" to change the HTML after the region has been rendered -- hence we see BEFORE shown on the screen. (I'll have to think about what a Dynamic Action does.)
    Also, if a page item has a default value, say 'DEFAULT' then that value doesn't get into the session state. At least, not with my current settings. Oh, that explains a lot of confusion!! I suppose there's a logical reason for this but who would expect default values to be differently from other PL/SQL operations on the item?
    Questions:
    1) So why does a default value not get put into the session state?Several reasons, among them:
    *1. When/why is the value required?* Region items (and thus their source and default values) are rendered in region/item sequence order. The item's source/default value would therefore not be available in session state until it's rendering point. This is frequently later in page show processing than the value is actually required, such as the common use case of including a data value in the page or region title. Setting the value in a Before Header/Regions computation or process makes it available as required before the item is actually rendered.
    *2. The rendered page might not be submitted.* Default values are typically set when a page will create a new row. Consider the situation where the user clicks a "Create" button and is presented with an order entry form containing several default values. They then decide they don't want to create a new order after all, and navigate away from the form page via some mechanism that uses a redirect rather than a submit (such as a default "Cancel" button). This means that no page submit processing is performed, and generally that no session state management is performed. If the default values were set in session state, the order entry page would contain the default values for the non-existent order despite the user never submitting it. This may have unwanted side-effects if these values are referenced elsewhere in the application, and therefore would require extra session state management to be built into the application.
    *3. A rendered item might not be submitted with the page.* Per the HTML specification, the values of disabled controls unchecked checkboxes are not POSTed on page submit. Consider a situation where a checkbox item is set with several default values, but the application requires that the checkboxes be cleared and disabled by a dynamic action if the user chooses certain options from a select list. In this case, on page submission no values are submitted into session state for the checkbox item. If the defaults had been set in session state, then the application would be in an inconsistent state, with the user-selected option indicating that none of the checkboxes were checked, but with session state holding values showing that they were. This would require additional processing to ensure that the application's state was consistent before saving it to the database.<sup>1</sup>
    2 & 3 are particularly significant in basic wizard-generated applications. Doing things in this way, the wizard-generated DML and navigation "just works", without the need for additional session state management.
    2) Is there a Page Item setting that causes the default value to be saved to the session state?No. Hopefully the explanations above provide sufficient reason to show why this is genearlly not desirable. On the rare occasions when it is required, set the session state value using a computation or process.
    <sup>1</sup> There are other reasons&mdash;mainly security related&mdash;that make it good practice to perform such checks in more complex and internet-facing applications anyway.

Maybe you are looking for

  • Zonelarm on windows XP pro blocks firefox after update to 3.6.8. Is zonealarm or firefox at fault?

    I've used firefox on windows XP (4 users) pro since version 2.x. I was happily applying every update until 3.6.7+(?). After installing update 3.6.8 my internet browser access stopped working (I'm using Opera for the first time to write this). I've do

  • BPEL 10.1.3 - TCP tunneling issue

    Hi, this my config: SOA Suite 10.1.3 Jdeveloper 10.1.3 (with web browser and proxy set to null) I don't understand how to configure obtunnel.bat to see sopa message between a webs ervice (deployed on localhost:80) and his parterlinks. This is what I

  • Substitution Variable in Data Load Rule

    Hello, Is it possible to filter selected record or rejected record from a flat file using a substitution variable ? I use the v11.1.1.3. Thanks Rgds, Pierre

  • Auto-play audio in Iweb

    Does Iweb support automatic audio play when site is opened capibilities?

  • Forms10g+jre1.6,  How to work on IE7 or Firefox

    Here is my html code, it works fine on ie6 but doesnt work with ie7 and firefox. (formsweb.cfg jipi parameters has been set.) html code: <object classid="clsid:CAFEEFAC-0016-0000-0004-ABCDEFFEDCBA"      align="baseline" border="0" width="250" height=