Retrieving clob locator

I am having trouble retrieving a clob locator from a column despite being able to set it in a previous statement. The clob is always returned as null.
This happens to both an 8.1.6 and 8.1.7 with the latest classes12.zip
Thanks,
-elliott
Here is my code snippet:
oracle.sql.CLOB clob = null;
// Select LOB locator into standard result set.
StringBuffer sSelect = new StringBuffer();
sSelect.append("SELECT " + mercColName + " FROM BUG" + whereClause.toString() + "FOR UPDATE");
debug.println("Get Clob: " + sSelect.toString());
ResultSet rs =
stmt.executeQuery(sSelect.toString());
while (rs.next()) {
// Get LOB locator into Java wrapper classes.
try {
clob = (oracle.sql.CLOB) rs.getClob(1);
catch (Exception ex) {
//do nothing
if (clob == null)
//update row
StringBuffer sUpdateClob = new StringBuffer();
sUpdateClob.append("UPDATE BUG SET " + mercColName + " = (empty_clob()) " + whereClause.toString());
debug.println("Update Clob: " + sUpdateClob.toString());
stmt.execute(sUpdateClob.toString());
m_DelayConnection.commit();
ResultSet rs2 =
stmt.executeQuery(sSelect.toString());
while (rs2.next()) {
// Get LOB locator into Java wrapper classes.
clob = (oracle.sql.CLOB) rs2.getObject(1);
java.io.Writer writer;
// read data into a character array
char[] data = pval.toCharArray();
// write the array of character data to a CLOB
writer = clob.getCharacterOutputStream();

Found the problem. I was using the ODBC driver instead of the JDBC driver.

Similar Messages

  • Retrieving CLOB

    Hello experts,
    I am following the link:
    https://forums.oracle.com/thread/725735
    First, I am only trying to retrieve clob data (>32 k) from db to a Rich Text Editor field in apex app. I am not getting success for that field at all irrespective of how long is the text in db CLOB column. Using apex 4.0
    I did three things:
    1. added clob_get function in HTML Header and Body attribute of the page
    2. added anonymous block as On Load-after header process . The code populates collection named CLOB_CONTENT from db CLOB column
    3. added following code in Footer of the region which is holding Rich Text Editor item:
    <script type="text/javascript">
    <!--
    addLoadEvent(clob_get);
    //-->
    </script>
    But still the item does not get populated with any data. I feel either step3 is wrong ( I mean I may need to define addLoadEvent somewhere) or I am missing something else. Looks like clob_get function is not getting executed.
    Please help.
    Thanks,
    RN

    Might a plug-in be useful instead?
    http://www.danielmcghan.us/2013/04/enkitec-clob-load-plug-in-for-apex-in.html
    Scott

  • HY000 error retrieving CLOB-data from oracle database via ODBC

    Hello,
    I get error HY000 [Oracle][ODBC][ORA] ORA-00932: inconsistent datatype when I want to show a CLOB column in my crystal report. The type of the field in the report is memo - in the database it is CLOB.
    How to retrieve CLOB-data from an Oracle 11GR2 database via ODBC in Crystal Report Version 12.3.0.601?
    Thanks in advance for any help.
    kind regards
    Monika Anna

    Hello,
    Who's ODBC driver are you using?
    Try our DataDirect drivers - https://smpdl.sap-ag.de/~sapidp/012002523100008666562008E/cr_datadirect53_win32.zip
    Thank you
    Don

  • Stolen Ipad.  Can I retrieve the location history?

    My ipad was stolen last week.  I used "find my iphone" to send a message, lock the device, and send me an email when it connected to a wifi network.  These actions were not executed since it was not connected.  That is, until today.  I received emails today that said the message was displayed and the ipad was locked at 1:44pm today.  What I still do not know is where it was when this occured. 
    I've read that "find my iphone" retains the last location for up to 24hrs, but it does not show the location when I log in now.  Can someone tell me if I can retrieve the location history?  Or perhaps it didn't stay online long enough to determine the location.  Any thoughts or suggestions would be greatly appreciated.

    Change your iTunes (Apple ID) password along with any other password that was stored in the iPod.  If any passwords are associated with credit cards, contact the CC company and get your card replaced (with a new number).  If any passwords are associated with your bank or any savings institution, contact them also and discuss approprate action with them.
    The "Find my..." function is pretty much useless if the device is in the hands of a thief.  All that is necessary is for the thief to connect to any computer with iTunes and "Restore as new."
    The only real protection you have is with the personal information on the device rather than the physical device itself.  Something as small as an iPod should have a strong 8-digit (or longer) password AND be configured for automatic wipe in the event of ten consecutive incorrect password entries.

  • How can I programmatically retrieve Cursor Locations from 3D Measurement Tool window

    I like to know if there is API which allows me to retrieve cursor locations shown on the 3D Measurement Tool window.
    Thanks

    I'm sorry I missed this request. :-(
    To accomplish your goal, you could use a MouseEventHandler, which would report back mouse positions in the 3D window (known as the canvas). You can get momentary positions on events such as MouseDown or MouseUp, or if you really need it, you can obtain real-time mouse positions using MouseMove.
    Here's a hunk of example code:
    //===================================================
    myMouseHandler = new MouseEventHandler();
    myMouseHandler.onMouseDown = true; //this prop is true by default
    myMouseHandler.reportAllTargets = false;
    myMouseHandler.onEvent = function(event)
    console.println("canvasPixelHeight = " + event.canvasPixelHeight );
    console.println("canvasPixelWidth = " + event.canvasPixelWidth );
    console.println("mouseX = " + event.mouseX );
    console.println("mouseY = " + event.mouseY );
    console.println("currentTool = " + event.currentTool );
    console.println("isMouseDown = " + event.isMouseDown );
    console.println("isMouseOut = " + event.isMouseOut );
    console.println("isMouseOver = " + event.isMouseOver );
    //Register the handler and turn the mule on
    runtime.addEventHandler(myMouseHandler);
    //===================================================

  • How to store and retrieve clob data fields

    Hai al l,
    How to sotre resumes of a Jobseekers in Oracle Data Base.Which version is enough(8i or 9i) and CLOB or BLOB is Preferable.
    Now my requirement is to insert the all the Attachments into Oracle database. I have little bit knowledge on inserting image file into DB. Now I want to insert More than 1000000 resume Attachments (all are .doc or .rtf files).Can you suggest me on this with a sample program .I am really thankful to all of our Members support and Valuable doubt clarifications.
    I am waiting for your valueble reply
    thanks in advance
    Kanchnaa
    I am really thankful for your support and Valuable doubt clarifications.

    CLOBs and BLOBs are physically stored just like any other Oracle data type, in the data files that make up the database, the .dbf files. They're not stored as seperate files that you can use outside of Oracle.
    Oracle has a seperate special data type for binary objects stored outside the database, the BFILE data type. However, this type is read-only from a database connection (and therefore from JDBC); the files have to be placed on the Oracle server some other way and the BFILE object is created as a pointer to that external resource. I think built-in stored procedures are used to actually read the data from the binary object.
    I've never used this datatype and can't tell you much more about it. See the documentation:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref175

  • Error retrieving Clob

    Here's my code:
    Statement stmt= conn.createStatement();
    String sql= "select clob from table";
    ResultSet rs= stmt.executeQuery(sql);
    while (rs.next()) {
    Clob clob= ((ResultSet)rs).getClob("clob");
    String tmpClob= clob.getSubString(1, 1500);
    System.out.println(tmpClob);
    I get the following error:
    java.lang.AbstractMethodError: oracle/jdbc/driver/OracleResultSet.getClob
    Any ideas?

    coreect like the follwing:
    Clob clob= ((ResultSet)rs).getClob(1);
    // 1 is the column index of clob data in the table
    // In "select clob from table", 'table' is the name of the table? if not
    // provide the appropriate table..

  • Unable to retrieve CLOB data from oracle

    hello I am trying to retreive a clob data from database. I am passing "country" to get "information". after submitting data it is showing SQLException caught: General error .
    whatz wrong.? can anybody help?
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class ClobTest2 extends HttpServlet{
         public void doGet( HttpServletRequest req, HttpServletResponse res )
              throws ServletException, IOException
                   Connection conn = null;
                   Statement st = null;
                   ResultSet rs = null;
                   res.setContentType( "text/html" );
                   PrintWriter out = res.getWriter();
                   String coun$ = "";
                   coun$ = req.getParameter( "coun" );
                   try{
                      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
                      conn = DriverManager.getConnection( "jdbc:odbc:clobtester",    "temp", "sol" );
                      st = conn.createStatement();
                      rs = st.executeQuery( "SELECT information FROM testclob WHERE country = '"+coun$+"' ");
                        while( rs.next() )
                         out.println(rs.getClob(1) );
                      catch( ClassNotFoundException e )
                           out.println( "Could not load database driver" + e.getMessage() );
                      catch( SQLException e )
                           out.println("SQLException caught: " + e.getMessage()  );
                    e.printStackTrace();
                   catch( Exception e )
                       System.err.println( "Problem closing the database" );
                 try{
                             st.close();
                             conn.close();
                         }catch( Exception e )
                            System.err.println( "Problem closing the database" );
         }

    certainly but this problem can go on several
    category. and I am the needy one to get the solutionHowever I don't need to answer cross-posted questions. And I don't.

  • Any body know of a Java Script for retrieving learner location from LMS; similar to name?

    Looking for  a script to pull learning location from LMS. Then based on location send them to a particular slide. Any help would be appreciated.
    Example: learning from Chicago gets slide 2. LA slide 3, and so fourth...

    Are you using Captivate 8, so that you have access to the system variable cpInfoGeoLocation? And are your users on a device that has detection of location activated?
    For the JS you'll have to wait for someone else, but I think this information is necessary. And since you don't want to try advanced/shared actions...just wait.

  • Error when retrieving oracle clobs

    Here's the sql statement that we are running:
    SELECT dbms_lob.substr(sql_statement,dbms_lob.getlength(sql_statement),1) sql_statement FROM query
    WHERE query_tk = [Param.1]
    If the sql_statement is > 4000 chars, we are getting this error:
    Fatal Error
    A SQL Error has occurred on query, ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 1 .

    We are seeing this outside of xmii as well. 
    Here's the background.  We originally tried to do a normal insert to the clob (thru xmii) but we got errors when inserting values of more than 4000 chars.  So, we inserted the clob differently (code used below).  That's when we started getting this new error.  Is there another way to insert/retrieve clobs?
       --INSERT "base" row if it does not already exist.
       BEGIN
         SELECT  query_tk
           INTO  v_dummy
           FROM  query
           WHERE query_tk = p_query_tk;
         EXCEPTION
           WHEN NO_DATA_FOUND THEN
             INSERT INTO query
               (query_tk
               ,last_updated_timestamp
               ,sql_statement
             VALUES
               (p_query_tk
               ,SYSDATE
               ,'DUMMY');
       END;
       --Initialize buffer with data to be inserted
       v_copy_length := LENGTH(p_sql_statement);
       -- get LOB handle
       SELECT  sql_statement
         INTO  v_lobloc
         FROM  query
         WHERE query_tk = p_query_tk
         FOR UPDATE;
       dbms_lob.write(v_lobloc,v_copy_length,1,p_sql_statement);

  • Select with CLOB datatype

    Hi all....
    I must create a view to retrieve the data from a table "texto_email" ... and that table has a field named Texto - datatype CLOB. This field has some html definitions and formating tags.
    but when i create the view, i get a error in plsql saying "view created with compilation errors"
    when i coment " -- " the line responsable for the CLOB field, its created sucesful.
    what I´m doing wrong? there´s a something diferent to do in this case?
    that is my view... if someone can help...
    CREATE OR REPLACE FORCE VIEW vw_texto_email
    AS
    SELECT DISTINCT
    te.id_texto_email
    ,te.id_texto_email_tipo as id_tet
    ,te.data_cadastro
    ,te.data_inicio
    ,te.descricao
    ,te.assunto
    ,te.texto AS texto ---- that is the CLOB field -
    ,tet.descricao as tipo_email
    FROM
    texto_email te
    ,texto_email_tipo tet
    WHERE
    te.id_texto_email_tipo = tet.id_texto_email_tipo
    tnks....

    To work with LOBs you have to know something about the concept of a LOB locator( a short tour in the documentation would be appreciable).
    A LOB locator is a pointer to large object data in a database.
    Database LOB columns store LOB locators, and those locators point to the real data stored in a LOB data.
    To work with LOB data, you have to:
    1) Retrieve LOB locator
    2) Use a built-in package named DBMS_LOB to modify LOB
    2.1 Open lob
    2.2 ...
    2.3 read/write LOB
    2.4 close LOB
    Why do you want to retrieve a lob locator in a view?
    Stated that you could retreive its state in :
    1 null
    2 empty
    3 populated with a valid pointer to data

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

  • OCCI Clob.write problem

    hi
    i am new to occi
    i have tested my application and insert data to my tables ;
    I have a field in my table which its type is clob and a procedure for inserting in that table
    when i test procedure with stmt.setString (for the clob field) I have no problem for inserting
    but when using stmt->setClob , there is exception ora-22275
    my code is like this:
    Clob C(conn);
    C.setEmpty();
    C.write(4,"test",4);
    stmt->setClob(1,C);
    stmt->executeUpdate();
    whats wrong?
    error message is about problem in occi::clob::write

    Hi,
    Because LOBs use what are known as locators, you can't just create the clob in client code like that and insert it into the database.
    The database won't "know about" the locator and will raise the ORA-22275 error (as you have discovered).
    What you need to do is initialize the clob as noted in the Clob Class documentation notes. See here for example:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/reference009.htm#i1118691
    An uninitialized CLOB object can be initialized by:
    * The setEmpty() method. The CLOB can then be modified by inserting this CLOB into the table and retrieving it using SELECT ... FOR UPDATE....
    < emphasis added >
    So, essentially, you set the clob to empty, insert it into the table, then using "select for update" you get the clob (locator) back. You need to use "select for update" and not just a regular select. You can then modify the empty clob (be sure to commit when done).
    For an example of this, see the Oracle 10g Release 1 Demos from here:
    http://www.oracle.com/technology/sample_code/tech/occi/index.html
    Regards,
    Mark

  • Can not Load CLOB data 32k to target table

    SQL> DESC testmon1 ;
    Name Null? Type
    FILENAME VARCHAR2(200)
    SCANSTARTTIME VARCHAR2(50)
    SCANENDTIME VARCHAR2(50)
    JOBID VARCHAR2(50)
    SCANNAME VARCHAR2(200)
    SCANTYPE VARCHAR2(200)
    FAULTLINEID VARCHAR2(50)
    RISK VARCHAR2(5)
    VULNNAME VARCHAR2(2000)
    CVE VARCHAR2(200)
    DESCRIPTION CLOB
    OBSERVATION CLOB
    RECOMMENDATION CLOB
    SQL> DESC test_target;
    Name Null? Type
    LOCALID NOT NULL NUMBER
    DESCRIPTION NOT NULL CLOB
    SCANTYPE NOT NULL VARCHAR2(12)
    RISK NOT NULL VARCHAR2(6)
    TIMESTAMP NOT NULL DATE
    VULNERABILITY_NAME NOT NULL VARCHAR2(2000)
    CVE_ID VARCHAR2(200)
    BUGTRAQ_ID VARCHAR2(200)
    ORIGINAL VARCHAR2(50)
    RECOMMEND CLOB
    VERSION VARCHAR2(15)
    FAMILY VARCHAR2(15)
    XREF VARCHAR2(15)
    create or replace PROCEDURE proc1 AS
    CURSOR C1 IS
    SELECT FAULTLINEID,VULNNAME,scanstarttime, risk,
    dbms_lob.substr(DESCRIPTION,dbms_lob.getlength(DESCRIPTION),1) "DESCR",dbms_lob.substr(OBSERVATION,dbms_lob.getlength(OBSERVATION),1) "OBS",
    dbms_lob.substr(RECOMMENDATION) "REC",CVE
    FROM testmon1;
    c_rec C1%ROWTYPE;
    descobs clob;
    FSCAN_VULN_TRANS_REC VULN_TRANSFORM_STG%ROWTYPE;
    TIMESTAMP varchar2(50);
    riskval varchar2(10);
    pCTX PLOG.LOG_CTX := PLOG.init (pSECTION => 'foundscanVuln Procedure',
    pLEVEL => PLOG.LDEBUG,
    pLOG4J => TRUE,
    pLOGTABLE => TRUE,
    pOUT_TRANS => TRUE,
    pALERT => TRUE,
    pTRACE => TRUE,
    pDBMS_OUTPUT => TRUE);
    amount number;
    buffer varchar2(32000);
    BEGIN
    ---INITIALIZE THE LOCATOR FOR CLOB DATA TYPE
    select observation into descobs from testmon1 where rownum=1;
    OPEN C1;
    loop
    fetch C1 INTO c_rec;
    exit when C1%NOTFOUND;
    --LOAD THE DESCRIPTION FIELD FROM CURSOR AND WRITE IT TO THE CLOB LOCATOR descobs.
    dbms_lob.Write(descobs,dbms_lob(c_rec.DESCR),1,c_rec.DESCR);
    ------APPEND THE OBSERVATION FIELD FROM CURSOR TO THE CLOB LOCATOR descobs.
    dbms_lob.Writeappend(descobs,dbms_lob(c_rec.DESCR),c_rec.OBS);
    -- dbms_output.put_line ('the timestamp is :'||c_rec.scanstarttime);
    --dbms_lob.write(descobs,amount,1,buffer);
    descobs:=c_rec.OBS;
    --dbms_lob.read(descobs,amount,1,buffer);
    --dbms_lob.append(c_rec.DESCR,c_rec.OBS);
    --descobs:=c_rec.OBS;
    --dbms_output.put_line ('the ADDED DESCROBS is :'||dbms_lob.substr(c_rec.DESCR,dbms_lob.getlength(c_rec.DESCR),1));
    dbms_output.put_line ('the ADDED DESCRIPTION AND OBSERVATION is :'||descobs);
    --dbms_output.put_line ('the DESCROBS buffer  is :'||buffer);
    SELECT DESCRIPTION INTO FSCAN_VULN_TRANS_REC.DESCRIPTION
    FROM TESTMON1 WHERE ROWNUM=1;
    ---------LOAD THE DESCRIPTION+ observation value into the target table description
    DBMS_LOB.WRITE(FSCAN_VULN_TRANS_REC.DESCRIPTION, dbms_lob.getlength(descobs),1,descobs);
    TIMESTAMP:=substr(c_rec.scanstarttime,1,10)||' '|| substr(c_rec.scanstarttime,12,8);
    IF c_rec.risk <3
    THEN riskval:='Low';
    ELSIF c_rec.risk <6
    THEN riskval:='Medium';
    ELSIF c_rec.risk <10
    THEN riskval:='High';
    END IF;
    FSCAN_VULN_TRANS_REC.TIMESTAMP:=TO_DATE(TIMESTAMP, 'YYYY/MM/DD HH24:MI:SS');
    FSCAN_VULN_TRANS_REC.risk:= riskval;
    --dbms_lob.append(c_rec.DESCR,c_rec.OBS);
    FSCAN_VULN_TRANS_REC.DESCRIPTION:=c_rec.DESCR;
    FSCAN_VULN_TRANS_REC.RECOMMEND:=c_rec.REC;
    FSCAN_VULN_TRANS_REC.LocalID:=to_number(c_rec.FAULTLINEID);
    FSCAN_VULN_TRANS_REC.SCANTYPE:='FOUNDSCAN';
    FSCAN_VULN_TRANS_REC.CVE_ID:=c_rec.CVE;
    FSCAN_VULN_TRANS_REC.VULNERABILITY_NAME:=c_rec.VULNNAME;
    -- dbms_output.put_line ('the plog timestamp is :'||timestamp);
    -- dbms_output.put_line ('the timestamp is :'||riskval);
    --dbms_output.put_line ('the recommend is :'||FSCAN_VULN_TRANS_REC.RECOMMEND);
    --dbms_output.put_line ('the app desc is :'||FSCAN_VULN_TRANS_REC.DESCRIPTION);
    insert into test_target values FSCAN_VULN_TRANS_REC;
    End loop;
    close C1;
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    -- dbms_output.put_line ('Data not found');
    -----------dbms_output.put_line (sqlcode|| ':'||sqlerrm);
    end proc1;
    using dbms_lob package is not helping. Either DB stops responding. Or the Observation field ( which has max length >300000) can not be loaed into a CLOB variable.
    Please help or give me a sample code that helps.

    select     
         BANKING_INSTITUTION.BANK_REF_CODE     C1_BANK_ID,
         BANKING_INSTITUTION.NAME_BANK     C2_BANK_NAME,
         BANKING_INSTITUTION.BANK_NUMBER     C3_BANK_NUMBER,
         BANKING_INSTITUTION.ISO_CODE     C4_GBA_CODE,
         BANKING_INSTITUTION.STATUS     C5_STATUS,
         BANKING_INSTITUTION.SOURCE     C6_SOURCE,
         BANKING_INSTITUTION.START_DATE_BANK     C7_START_DATE,
         BANKING_INSTITUTION.ADDRESS_BANK     C8_BANK_ADDRESS1
    from     REF_DATA_DB.BANKING_INSTITUTION BANKING_INSTITUTION
    where     (1=1)
    insert /*+ append */ into XXSVB.C$_0XXSVB_BANKS_STAGING
         C1_BANK_ID,
         C2_BANK_NAME,
         C3_BANK_NUMBER,
         C4_GBA_CODE,
         C5_STATUS,
         C6_SOURCE,
         C7_START_DATE,
         C8_BANK_ADDRESS1
    values
         :C1_BANK_ID,
         :C2_BANK_NAME,
         :C3_BANK_NUMBER,
         :C4_GBA_CODE,
         :C5_STATUS,
         :C6_SOURCE,
         :C7_START_DATE,
         :C8_BANK_ADDRESS1
    )

  • What's the best way to create and free temporaries for CLOB parameters?

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production on Solaris
    I have a procedure calling another procedure with one of the parameters being an IN OUT NOCOPY CLOB.
    I create the temporary CLOB in proc_A, do the call to proc_B and then free the temporary again.
    In proc_B I create a REFCURSOR, and use that with dbms_xmlgen to create XML.
    So the code basically looks like
    CREATE OR REPLACE PROCEDURE client_xml( p_client_id IN            NUMBER
                                           ,p_clob      IN OUT NOCOPY CLOB   ) AS
       v_rc         SYS_REFCURSOR;
       v_queryCtx   dbms_xmlquery.ctxType;
    BEGIN
       OPEN c_rc FOR
          SELECT col1
                ,col2
                ,col3
            FROM clients
           WHERE client_id = p_client_id;
       v_queryCtx := dbms_xmlgen.newContext(v_rc);
       p_clob     := dbms_xmlgen.getXML(v_queryCtx, 0);
    END;
    CREATE OR REPLACE PROCEDURE my_proc AS
       v_clob       CLOB;
       v_client_id  NUMBER;
    BEGIN
       v_client_id := 123456;
       dbms_lob.createTemporary(v_clob, TRUE, dbms_lob.CALL);
       client_xml( p_client_id => v_client_id
                  ,p_clob      => v_clob);
       dbms_lob.freeTemporary(v_clob);
    END;However, I just learned the hard way that IN OUT NOCOPY is only a hint, and that Oracle sometimes creates a local variable for the CLOB anyway.
    A solution is to change the client_xml procedure above to
    CREATE OR REPLACE PROCEDURE client_xml( p_client_id IN            NUMBER
                                           ,p_clob      IN OUT NOCOPY CLOB   ) AS
       v_rc         SYS_REFCURSOR;
       v_queryCtx   dbms_xmlquery.ctxType;
    BEGIN
       IF NOT NVL(dbms_lob.istemporary(p_clob),0) = 1 THEN
          dbms_lob.createTemporary(p_clob, TRUE, dbms_lob.CALL);
       END IF;
       OPEN c_rc FOR
          SELECT col1
                ,col2
                ,col3
            FROM clients
           WHERE client_id = p_client_id;
       v_queryCtx := dbms_xmlgen.newContext(p_refcursor);
       p_clob     := dbms_xmlgen.getXML(v_queryCtx, 0);
    END;My concern is that in case Oracle does create a local variable, 2 temporaries will be created, but there will only be 1 freeTemporary.
    Could this lead to a memory leak?
    Or should I be safe with the solution above because I'm using dbms_lob.CALL?
    Thanks,
    Arnold
    Edited by: Arnold vK on Jan 24, 2012 11:52 AM

    Arnold vK wrote:
    However, I just learned the hard way that IN OUT NOCOPY is only a hint, and that Oracle sometimes creates a local variable for the CLOB anyway.A CLOB variable in called a locator. Just another term for a pointer.
    A CLOB does not exist in local stack space. The variable itself can be TBs in size (max CLOB size is 128TB depending on DB config) - and impossible to create and maintain in the stack. Thus it does not exist in the stack - and is why the PL/SQL CLOB variable is called a locator as it only contains the pointer/address of the CLOB.
    The CLOB itself exists in the database's temporary tablespace - and temporary LOB resource footprint in the database can be viewed via the v$temporary_lobs virtual performance view.
    Passing a CLOB pointer by reference (pointer to a pointer) does not make any sense (as would be the case if the NOCOPY clause was honoured by PL/SQL for a CLOB parameter). It is passed by value instead.
    So when you call a procedure and pass it a CLOB locator, that procedure will be dereferencing that pointer (via DBMS_LOB for example) in order to access its contents.
    Quote from Oracle® Database SecureFiles and Large Objects Developer's Guide
    >
    A LOB instance has a locator and a value. The LOB locator is a reference to where the LOB value is physically stored. The LOB value is the data stored in the LOB.
    When you use a LOB in an operation such as passing a LOB as a parameter, you are actually passing a LOB locator. For the most part, you can work with a LOB instance in your application without being concerned with the semantics of LOB locators. There is no requirement to dereference LOB locators, as is required with pointers in some programming languages.
    >
    The thing to guard against is not freeing CLOBs - the age old issue of not freeing pointers and releasing malloc'ed memory when done. In PL/SQL, there is fairly tight resource protection with the PL/SQL engine automatically releasing local resources when those go out of scope. But a CLOB (like a ref cursor) is not really a local resource. And as in most other programming language, the explicit release/freeing of such a resource is recommended.

Maybe you are looking for

  • Final Cut Pro X and AVCHD 1080p25?

    I'd like to edit AVCHD videos from my Canon Legria HF-S20 @1080p25 in native AVCHD mode (without ProRes conversion). I've read that this is possible for 1080i50/60 videos but not for 1080p50/60... but what about 1080p25?

  • Problem with Waveform Chart updating

    Hi! I have written a LabVIEW project for 8510. I have a problem with the waveform chart not updating the data incoming to it. that is, Y axis does not update according to 8510 display format. May you help me? Attachments: Network_Analyzer_8510C_nazan

  • Cursor using variable table name

    I'm new to Oracle, and am wondering if I can create a cursor that can take a variable name as the table it's selecting from. I am working on an application that is loading data to 1 of 3 tables. The table name is stored as a variable and the loads ar

  • Backup/Synchronization Warning Hard Drive Almost Full

    Every time I try to create an album in Photoshop Elements 10, when it goes to upload to Photoshop.com, I get a warning that my hard drive is almost full. If I repeatedly indicate I have fixed the problem, the album will eventually synchronize.  My ha

  • Urgent help on highwater mark

    In Dw database, i have tablespace of 1.2TB size in that used segment only 300GB and rest of 900GB is free space. I am not able to shrink the datafiles it throws me ORA-03297, i run shrink space compact and shrink space based on segment advisor report