TopLink JPA doesn't persist Clob field when useStringBinding

I'm using Toplink JPA on a JSF application deploying on Tomcat.
Everything works fine except the table with Clob field.
When insert data with size larger than 4KB, the error will occur.
I did some searching and I fixed this by using SessionCustomizer.
In my persistence.xml I put this
<property name="toplink.session.customizer" value="com.my.sessions.MySessionCustomizer"/>
and MySessionCustomizer is like this
public class MySessionCustomizer implements SessionCustomizer {
     public void customize(Session session) throws Exception {
          DatabaseLogin login = session.getLogin();
          login.useStringBinding();
          login.setShouldBindAllParameters(false);
          login.dontCacheAllStatements();
Things seem to work fine now but I found that Toplink does not persist the field that useStringBinding in database (Oracle 9i)
eg. when I update an object into a table which has 1 clob field and some other field like VARCHAR2, all the data in non-clob fields are stored perfectly in Oracle but the data in Clob field just gone blank. It just gone blank in the database but in my application, it's still there. I mean as long as my session is still alive, everything seems to work fine from the application side. But when I start a new session, the data in the Clob is lost because it's not in the database.
Why is this happening? Do I need to do anything extra when useStringBinding?
It seems to me that the field with StringBinding just don't get into the database.
Could somebody help me with this?

This is an issue with the Oracle thin JDBC driver in that it has a 4k limit for LOBS. The best workaround is to use the Oracle OCI JDBC driver, which does not have this limitation (I think this limitation was also improved in the Oracle 10.2 thin JDBC driver).
If you are using TopLink 10.1.3 a workaround to the JDBC issue is provided by using the Oracle9Platform and configuring the mapping for the CLOB to have a field-classification of java.sql.Clob.class.
If you are using TopLink Essentials unfortunately this support is not currently available. I believe there is already an issue logged for this in Glassfish. If you cannot use the OCI driver you may need to insert the CLOB data using direct JDBC code.

Similar Messages

  • ASP & Clob fields in the Oracle Database 8i

    Hi All,
    This is the first time I am posting a question. We are having a problem interfacing ASP pages with Clob fields int he Oracle Database.
    We are trying to display clob fields in an oracle database from ASP PAge. The ASP Page does a select to a clob field from a table. But we lose the formatting od the data inside the clob field when we display it out using ASP. We display it as a
    single stream of data. But when we display the clob using SQLPLUS we do see the formatted data.
    How can we solve this issue or circumvent it ?
    We are not looking to parse through the clob field in ASP, rather we already have a stored procedure that parses the data for us. The parsed data is then stored in a clob field already formatted the way we need it. The problem occurs when the ASP
    page reads the clob field. The ASP page reads it as one continuos string instead of the formatted data that exists in the clob field.
    I imported the data from Oracle to Access in order to view the raw data. The data is shown formatted properly in Access, so we know our stored procedure is doing what it supposed to do. As far as getting the data to display. The only way to retrieve (as far as I know) a clob field using ASP is by a built in function called GetChunk(). Is there a better method of displaying the formatted data aside from parsing on the client side, using ASP?
    Let me know if anyone has a solution to this problem.
    Thanks for your help and time. Sanjiv.

    Sanjiv, you might want to try some of the Windows development forums:
    ODBC: http://forums.oracle.com/forums/forum.jsp?id=763957
    New .NET provider forum: http://forums.oracle.com/forums/forum.jsp?id=1015160
    Oracle Objects for OLE: http://forums.oracle.com/forums/forum.jsp?id=763961
    Oracle Provider for OLE DB: http://forums.oracle.com/forums/forum.jsp?id=763961
    Oracle Services for MTS: http://forums.oracle.com/forums/forum.jsp?id=763960
    You'll reach a more appropriate audience than just the Web services audience.
    Mike.

  • Couldn't persist OneToMany JoinColumn/JoinTable (Unidir) using TopLink JPA

    Hi All,
    I am having a lot of difficulty deploying a OneToMany Unidirectional (Zipcode) record which consist of multiple Zipnames using TopLink on Glassfish v2r2, JDK1.6.0_06, MySQL 5.0, Netbeans 6.1 and Windows XP platform.
    Below are the relevant EJBs snippets:
    Zipcode class
    @Entity
    @Table(name="ZIPCODE")
    public class Zipcode implements Serializable {
    @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
    @JoinColumn(name="ZIPCODE_ID")    
                 or
        @JoinTable(name="ZIPCODE_ZIPNAME",          
                   joinColumns={@JoinColumn(name="ZIPCODE_ID")},
                   inverseJoinColumns={@JoinColumn(name="ZIPNAME_ID")})
        private Collection<Zipname> zipnames = new ArrayList<Zipname>();
        public Collection<Zipname> getNames()
         return zipnames;
        public void setZipnames(Collection<Zipname> zipnames)
         this.zipnames = zipnames;
    Zipname class does not maintain relationship back to Zipcode.
    public class ZipcodeApplicationClient {
    @PersistenceContext(unitName="GeographicalDB-PU")
    private static EntityManager manager;
        public ZipcodeApplicationClient() {
        public static void main(String[] args) {
            try {
                Zipcode zipcode_1 = new Zipcode();
                zipcode_1.setcode(9001);
                Zipname zipname_1 = new Zipname();
                zipname_1.setName("Harbour Cove");
                zipcode_1.getNames().add(zipname_1);
                // Can add one Zipname record with JoinTable but not JoinColumn
                Zipname zipname_2 = new Zipname();
                zipname_2.setName("Wonderland");
                zipcode_1.getNames().add(zipname_2);
                manager.persist(zipcode_1);   // line 45
    The same deployment error message below was generated from both JoinColumn and JoinTable methods:
    run-deploy:
    run-display-browser:
    run-ac:
    Copying 1 file to C:\Documents and Settings\Jack\GeographicalBean\dist
    Caught an unexpected exception!
    java.lang.NullPointerException
            at client.ZipcodeApplicationClient.main(ZipcodeApplicationClient.java:45)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
            at com.sun.enterprise.appclient.Main.main(Main.java:200)
    run-InvestmentBean-app-client:The JoinColumn method would not work for one Zipname record. On the other hand, JoinTable approach would allow us to add a single Zipname record without error out.
    Q1. Can you confirm whether TopLink JPA 1.0 (Glassfish v2r2) support OneToMany JoinColumn Unidirectional at all?
    Q2. Does TopLink JPA 1.0 (Glassfish v2r2) support OneToMany JoinTable Unidirectional? If so, what is the cause of this issue? Otherwise, please make appropriate recommendation steps to take.
    This question has been posted on http://forums.sun.com/thread.jspa?threadID=5330670&tstart=0 and http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=78&t=004489&p=1 earlier in the hope a quicker response.
    Your guidance would be very much appreciated.
    Many thanks,
    Jack

    Hi,
    Below are some more error output from the OneToMany JoinTable Unidirectional approach:
    pre-run-deploy:
    Initial deploying InvestmentBean to C:\Documents and Settings\abc\InvestmentBean\dist\gfdeploy
    Completed initial distribution of InvestmentBean
    Start registering the project's server resources
    Finished registering server resources
    moduleID=InvestmentBean
    deployment started : 0%
    deployment finished : 100%
    Deploying application in domain completed successfully
    Trying to create reference for application in target server completed successfully
    Trying to start application in target server completed successfully
    WARNING:
    JDO76614: Deployment encountered SQL Exceptions:
    JDO76609: Got SQLException executing statement "CREATE TABLE ZIPCODE (ID INTEGER NOT NULL, DIALING_CODE VARCHAR(255), TIME_ZONE VARCHAR(255), CODE INTEGER, NEAREST_AIRPORT VARCHAR(255), LONGITUDE VARCHAR(255), NEAREST_TRAIN_STATION VARCHAR(255), NEAREST_URBAN_CENTRE VARCHAR(255), HOTELS VARCHAR(255), LATITUDE VARCHAR(255), NEARBY_FEATURES VARCHAR(255), COUNCIL VARCHAR(255), LOCALITY VARCHAR(255), PRIMARY KEY (ID))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zipcode' already exists
    JDO76609: Got SQLException executing statement "CREATE TABLE ZIPCODE_ZIPNAME (ZIPCODE_ID INTEGER NOT NULL, ZIPNAME_ID INTEGER NOT NULL, PRIMARY KEY (ZIPCODE_ID, ZIPNAME_ID))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zipcode_zipname' already exists
    JDO76609: Got SQLException executing statement "CREATE TABLE ZIPNAME (ID INTEGER NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zipname' already exists
    JDO76609: Got SQLException executing statement "ALTER TABLE ZIPCODE_ZIPNAME ADD CONSTRAINT FK_ZIPCODE_ZIPNAME_ZIPCODE_ID FOREIGN KEY (ZIPCODE_ID) REFERENCES ZIPCODE (ID)": java.sql.SQLException: Can't create table '.\geographicaldb\#sql-434_4.frm' (errno: 121)
    JDO76609: Got SQLException executing statement "ALTER TABLE ZIPCODE_ZIPNAME ADD CONSTRAINT FK_ZIPCODE_ZIPNAME_ZIPNAME_ID FOREIGN KEY (ZIPNAME_ID) REFERENCES ZIPNAME (ID)": java.sql.SQLException: Can't create table '.\geographicaldb\#sql-434_4.frm' (errno: 121)Enable of InvestmentBean in target server completed successfully
    Enable of application in all targets completed successfully
    All operations completed successfully
    post-run-deploy:
    run-deploy:
    run-display-browser:
    run-ac:
    Copying 1 file to C:\Documents and Settings\Jack\GeographicalBean\dist
    Caught an unexpected exception!
    java.lang.NullPointerException
    at client.ZipcodeApplicationClient.main(ZipcodeApplicationClient.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
    at com.sun.enterprise.appclient.Main.main(Main.java:200)
    run-GeographicalBean-app-client:
    run:
    I would like to correct an earleir comment where I stated that this method did work when adding a single Zipname record. This is no true.
    Thanks,
    Jack

  • Inserting to a CLOB field in Oracle 8i  Database

    Hi All,
    I am trying to insert a value to a CLOB field in Oracle 8i DB.
    The value gets inserted when the size is less (Up to around 80 Bytes).
    When the size becomes larger the insertion does not take place but no exception is thrown.
    Please see below the code I have written.
    PreparedStatement preparedStatement = null;
              try {
                   connection = getConnection(MMAKeys.WMDS_DATASOURCE);
                   String query = "UPDATE s_mmhp_batch SET MMHP_REPORT_CLOB=(?) WHERE MMHP_BATCH_ID=(?) AND MMHP_USER_ID=(?) AND MMHP_MEMBER_KEY=(?)";
              preparedStatement=connection.prepareStatement(query);
              Reader r = new StringReader(clobReport);
              preparedStatement.setCharacterStream(1, r, clobReport.length());
              oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(connection , false, oracle.sql.CLOB.DURATION_CALL);
              newClob.putString(1,clobReport);
              preparedStatement.setClob(1,newClob);
              preparedStatement.setInt(2,batchId);
              preparedStatement.setString(3,userId);
              preparedStatement.setString(4,memberKey);
              preparedStatement.executeUpdate();
              System.out.println("inside the write to Batch method after executing the query");
              } catch (SQLException exception) {
                   throw new DAOException(
                        "MREDMMSDAO -> writeToTable():SQLException"
                             + exception.getMessage());
              } catch (Exception exception) {
                   throw new DAOException(
                        "MREDMMSDAO -> writeToTable():Exception"
                             + exception.getMessage());
              } finally {
                   closeStatement(preparedStatement);
                   closeConnection(connection);
    I came to know that this method is not supported in Oracle 8i.
    I tried to create an empty CLOB and call the putValue() method.
    But Then, I got an exception stating that the method is not supported.
    Is there any other way to insert a CLOB value to Oracle 8i?
    Please help.
    Thanks in advance,
    Neelambary

    And cursor.callproc('insert_clob_proc', (clob,))
    doesn't work for you?
    PrzemekYes - I should have been more clear in my original post. The callproc function works until we have a value which is over 32K. At values over 32K, we get an error message "ORA-01460: unimplemented or unreasonable conversion requested". I believe this is because we are sending the value as a string and so we would need to figure out how to send as a CLOB in cx_Oracle? Here is some code to use to test if interested...
    Oracle (Oracle Database 10g Release 10.1.0.4.0 - Production):
    CREATE TABLE clob_test (CLOB_FIELD CLOB);
    CREATE OR REPLACE PROCEDURE ins_clob_test (v_clob_field IN CLOB)
    AS
    BEGIN
    INSERT INTO clob_test (clob_field) VALUES (v_clob_field);
    END ins_clob_test;
    Python (2.5):
    conn = cx_Oracle.connect(xhash['oraclelogin'])
    cursor = conn.cursor()
    clob_var = 'Some test data' * 10000
    cursor.callproc('ins_clob_test',(clob_var,))
    conn.commit()
    cursor.close()
    conn.close()
    I should also mention that I am the Oracle developer and not the Python programmer - my knowledge of Python is very limited. I would like the Python programmers to use the procedures (packages) I have created to do their inserts but this situation has caused them to put the SQL directly in their code.
    Thanks again for any assistance you can provide.
    Jason

  • Parsing xml in clob field remove non utf-8 characters

    hi all,
    i have an issue where a stored procedure runs during a nightly process and parses xml contained in a clob field. There are some records that contain non-utf8(they paste characters from word)characters and therefore the parse fails when using performing an xquery select against the clob field as xmltype. I was wondering if anyone knew of a handy way to handle such a situation? I have looked around a bit and not found anything that seemed tailored to my situation, and I would like something a bit more generic than doing a replace on individual characters that i have found causing issues...thx in advance! -- jp

    Hi,
    Like BluShadow I'm curious to see a test case...
    Depending on the way it's been created, the encoding declared in the XML prolog doesn't necessarily reflects the actual encoding of the content.
    What's your database character set, and version?
    Please also post the error message you get (LPX-00200 probably?).

  • Insert into a clob field in a procedure based form

    Hi,
    I have a table with a clob field. I wrote a procedure to insert into this table. Then I built a form based on this procedure. Here is my code:
    drop table clob_test;
    create table clob_test(id NUMBER, note CLOB);
    insert into clob_test values(10,empty_clob());
    Create or Replace PROCEDURE PROJECTS.SET_CLOB
    ( p_id IN CLOB_TEST.id%TYPE,
    p_note IN VARCHAR2 default null)
    as
    v_loc CLOB;
    v_amt binary_integer;
    v_pos integer :=1;
    v_clob varchar2(32000);
    Begin
    insert into clob_test values(p_id,empty_clob());
    v_clob := p_note;
    v_amt := LENGTH(v_clob);
    select note into v_loc from clob_test where id = p_id;
    DBMS_LOB.WRITE(v_loc,v_amt,v_pos,v_clob);
    End;
    When I try to insert into note field more than 4000 charaters. I got this error:
    An unexpected error occurred: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-16016)
    Why this happens? I know portal form doesn't support clob, but this procedure deal directly with database. Can anyone from Oracle give me help? Thanks in advance!

    I use a dynamic page instead of a form on the procedure. It's working.
    Apparently Oracle is not supporting a varchar2 more than 4000 in any form format, even using textarea for p_note.

  • Toplink-jpa and/or jdev11 problem

    Hi,
    How should I configure a toplink/jpa application in oc4j 11? Mine doesn't seem to be able to be able to connect... But I guess I didn't configure correctly.
    Anyway, it works in the jdevelopper 11 (technical preview) embedded oc4j. I can deploy it ok from jdeveloper, and even connect to the session beans on the server from another application (swing client, independant).
    But whenever my beans try to make a request, I get this exception:
    exception occurred during method invocation:
    javax.ejb.EJBTransactionRolledbackException: Exception [TOPLINK-4002] (Oracle
    TopLink - 11g Release 1 (11.1.1.0.0) (Build 070428)):
    oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Io exception: The Network Adapter could not establish
    the connectionError Code: 17002; nested exception is: Exception [TOPLINK-4002]
    (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070428)):
    I made a sample jdbc connection from the session bean, to the database it should connect to: no problem.
    Is there a checklist of what I should make sure? There are a lot of wizards, configuration files, etc. and I'm a little bit confused about the cause of the problem and how to fix it. My question has been on metalink for 48 hours, but without luck yet.
    Here is a more complete part of the stack trace:
    Caused by: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:72)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:105)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:168)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:224)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:495)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:429)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:650)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:200)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:413)
    at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:388)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:278)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:203)
    at oracle.oc4j.sql.DataSourceConnectionPoolDataSource.getPooledConnection(DataSourceConnectionPoolDataSource.jav
    a:57)
    at oracle.oc4j.sql.xa.EmulatedXADataSource.getXAConnection(EmulatedXADataSource.java:94)
    at oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl.createXAConnection(ManagedConnectionFactoryImpl.java:251)
    at oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:21
    2)
    at com.evermind.server.connector.ApplicationConnectionManager.createManagedConnection(ApplicationConnectionManager.java:1354)
    at oracle.oc4j.sql.OracleConnectionFactoryAdapter.createConnection(OracleConnectionFactoryAdapter.java:110)
    at oracle.ucp.common.CollectionConnectionPoolImpl.createOnePooledConnection(Coll
    ectionConnectionPoolImpl.java:513)
    at oracle.ucp.common.CollectionConnectionPoolImpl.borrowConnectionWithoutCountingRequests(CollectionConnectionPoolImpl.java:
    419)
    at oracle.ucp.common.CollectionConnectionPoolImpl.borrowConnection(CollectionConnectionPoolImpl.java:295)
    at oracle.oc4j.sql.OracleCommonConnectionPool.borrowConnection(OracleCommonConnectionPool.java:79)
    at oracle.oc4j.sql.OracleCommonConnectionPool.getManagedConnection(OracleCommonConnectionPool.java:61)
    at oracle.j2ee.connector.OC4JConnectionPoolAdapter.getManagedConnection(OC4JConnect
    ionPoolAdapter.java:543)
    at com.evermind.server.connector.ApplicationConnectionManager.getManagedConnectionContext(ApplicationConnectionManager.java:1568)
    at com.evermind.server.connector.ApplicationConnectionManager.getConnectionFromPool
    (ApplicationConnectionManager.java:1553)
    at com.evermind.server.connector.ApplicationConnectionManager.acquireConnectionContext(ApplicationConnectionManager.ja
    va:1499)
    at com.evermind.server.connector.ApplicationConnectionManager.allocateConnection(ApplicationConnectionManager.java:1444)
    at oracle.j2ee.connector.OracleConnectionManager.unprivileged_allocateConnection(OracleConnectionManager.jav
    a:238)
    at oracle.j2ee.connector.OracleConnectionManager.allocateConnection(OracleConnectionManager.java:192)
    at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:217)
    at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:147)
    at oracle.toplink.jndi.JNDIConnector.connect(JNDIConnector.java:123)
    ... 69 more

    HI
    can you reply the feedback of metalink? because I'm having similar problem.
    I debug in junit and embebbed at the jdev and it works well, but when I deploy in a standalone oc4j it gives me the same error of Excepção de E/S: The Network Adapter could not establish the connection
    And I'm not using 11g, I'm still in 10g but the problem might be the same.
    cumps
    DnlCY
    null

  • Toplink JPA schema generation problem in Glassfish

    I have problem getting Toplink to generate a proper mysql schema when run in Glassfish and using a mysql connection pool + jdbc datasource versus standalone toplink essentials and hardcoded jdbc url + user + password in the persistence.xml.
    It looks like it doesn't generate Mysql specific schemas but is reverting to some sort of general SQL schema. Toplink does recognize the database as a mysql database according to the log (by printing out platform=>MySQL4Platform).
    in an @Entity i have a field of type String[], in the standalone version it is mapped to a BLOB, probably using serialization or something. However if I use the exact same @Entity class in glassfish, it is mapped to a VARCHAR(255).
    I have a similar problem using a @Lob String, in the standalone version it is mapped to MEDIUMTEXT, but in the glassfish version it is mapped to TEXT
    In the log during deploy the database is recognized as a MySQL4Platform
    JDBC Driver version: mysql-connector-java-5.0.5
    Mysql version: MySQL Version: 5.0.37-log
    Glassfish is the bundled glassfish from Netbeans 5.5.1
    Has anybody seen this before?

    Seems like your database platform is incorrect. Are you setting the platform in your persistence.xml? I'm not sure how you were getting MEDIUMTEXT, none of the TopLink platforms use this type, did you create your own database platform class?

  • Need help with Java SE TopLink JPA project

    I'd like to ultimately run an Oracle stored procedure (connecting to Oracle 10g DB) in my Java SE program. I want to use TopLink JPA (11g) and if possible, use sessions to manage things - i.e. I want to run a stored procedure (that doesn't return anything), then run a native query. Does anyone have a good example of this type of configuration?
    I've been able to get it working with plain ol' JPA via TopLink - i.e. my persistence.xml is fine. Obviously, JPA doesn't define stored procedures, so I need to set it up to use stored procedures. I tried setting up my sessions.xml file - I think it's OK. However, I think my project.xml file is incorrect - and I don't think I even really understand it. But I want a project.xml that is very simple - does anyone have a simple, bare-bones project.xml example. All I plan to do is run the occasional stored procedure and run native queries (for now).

    If all you want to do is create extra stored procedure queries then you might want to consider just creating a customizer and adding some queries there. Then you won't actually need to create a project at all.
    Use the toplink.session.customizer property described at:
    http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html
    and then add some queries to your session. To make it even easier, then just define your queries in JPA, and override the call in your customizer. For example, if you defined a JPA named query called "Employee.executeStoredProc" then in your customizer method you could have something like:
    public void customize(Session session) {
    DatabaseQuery query = session.getQuery(“Employee.executeStoredProc”);
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("employee_stored_proc");
    query.setCall(call);
    Then when you call your JPA query the stored proc will run.

  • Crystal Report not showing fields when connected to a stored procedure

    I have a Stored Procedure that returns results when run in SQL Server, but when I add this to a Crystal Report it doesn't show any fields in the Field Explorer. But if I try any other SP, it works fine and I can see its fields.
    As you can see in the picture below, I am unable to expand the fields in the report while creating the report using standard report procedure too.
    I tried different ways, but nothing worked for me here. Please help me here.
    (FYI, I am using Crystal Reports 2008, SQL Server 2008R2)

    Hi Jamie,
    I just found out the reason for this issue.
    I wrote the stored procedure using the fields in the Datamart but the fields in the datamart in backend are connected to a different database which doesn't have SQL Server Authentication (for the Credentials) and that's the reason I was getting this issue.
    Once my BI team granted the permission, for that fields connecting to the backend database, I was able to see all fields in the Crystal Report.

  • Export XML data from a CLOB field using sql developer

    I have a table that contains a CLOB field, each record is a complete XML in itself. After running the select query i am exporting this data by right clicking on the answer set, while the export completes the data for each record gets truncated.
    When i chose to save the export in loader format i get the complete records but now there are n files created for n records exported.
    Is there a way i can get alll the records in a single file wirthout any truncation.
    Thanks in advance!

    You might try delimited format or csv, with no enclosures if desired.

  • Urgent: How to set a default value to CLOB field?

    Hi All,
    As per the requirements we have to populate the CLOB field in a template with default value with some template similar to a letter issued to clients in bank.
    So, every time when I insert a record in that table this CLOB field should have that letter template populated by default and user will modify that if required from GUI.
    How can I populate that CLOB field by default?
    Thanks!

    Something like this?
    ME_XE?
    create table test_clob
      pk_value number primary key,
      one_clob clob   default rpad('something', 32000, '*')
    insert into test_clob (pk_value) values (1);
    select * from test_clob;
    Table created.
    Elapsed: 00:00:00.13
    ME_XE?ME_XE?
    1 row created.
    Elapsed: 00:00:00.09
    ME_XE?ME_XE?
              PK_VALUE ONE_CLOB
                     1 something***********************************************************************
    1 row selected.
    Elapsed: 00:00:02.65
    ME_XE?ME_XE?
    ME_XE?ME_XE?select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    5 rows selected.
    Elapsed: 00:00:00.18
    ME_XE?

  • Export CLOB field (long= 4202083) to a file with UTL_FILE.PUT or PUT_LINE

    Hello,
    I'm trying to export a CLOB field to a txt file. It's a xml string in the CLOB. I have used different methods but the only which i can use is PUT, PUT_LINE.
    But:
    - PUT does only export the 32565 characters. I see that the output of l_pos is 4202084 but these are not exported. I have tried FFLUSH, but this gives a error or my syntax is not correct.
    - PUT_LINE is exporting the complete CLOB, but after every 32656 is new line is added and if I want to look with altove then I have to remove 129 times the new line. Thats not the way I want to go.
    Is it an idea, if it is possible, that I write 32565 chars to the buffer (file), read these 32565 from the buffer minus one (=without \r\n), delete the last 32565 chars from buffer and append/put the chars 32565 minus the \r\n to the buffer again. I hope there will be a better idea but....
    Has anybody an idea how I can solve this? Or what do I wrong?
    Any help would be appreciated.
    Beneath my code.
    Nico
    CREATE OR REPLACE DIRECTORY documents AS 'D:\TEST';
    SET SERVEROUTPUT ON
    DECLARE
      l_file    UTL_FILE.FILE_TYPE;
      l_clob    CLOB;
      l_buffer  VARCHAR2(32767);
      l_amount  BINARY_INTEGER := 32565;
      l_pos     INTEGER := 1;
      l_lengte  number;
      l_lineCount number := 0;
    BEGIN
      SELECT PAYLOAD
      INTO   l_clob
      FROM   icepayloadext ext
      WHERE  EXT.PAYLOADTYPE in ('POST')
        AND  substr(payload, 0, 2000) like '%181015%'
        AND  ext.LSTIME between to_date('10-10-2012 00:00:00', 'dd-mm-rrrr HH24:mi:ss') and to_date('10-10-2012 17:30:00', 'dd-mm-rrrr HH24:mi:ss');
      l_lengte := DBMS_LOB.GETLENGTH (l_clob);
      DBMS_OUTPUT.PUT_LINE('lengte clob veld: ' || l_lengte);
      l_file := UTL_FILE.fopen('DOCUMENTS', 'Sample1.txt', 'w', 32767);
      LOOP
        DBMS_LOB.read (l_clob, l_amount, l_pos, l_buffer);
        UTL_FILE.PUT(l_file, l_buffer);
        UTL_FILE.FFLUSH (l_file);
        --UTL_FILE.PUT_LINE(l_file,'alles geschreven');
        l_pos := l_pos + l_amount;
        DBMS_OUTPUT.PUT_LINE('Offset position: ' || l_pos);
        if (l_pos > l_lengte) then
            exit;
        end if;
      END LOOP;
      UTL_FILE.fclose(l_file);
    --EXCEPTION
      --WHEN OTHERS THEN
      --  DBMS_OUTPUT.put_line(SQLERRM);
        --UTL_FILE.fclose(l_file);
    END;
    /

    You can always try it the binary way:
    DECLARE
      l_file UTL_FILE.FILE_TYPE;
      l_clob CLOB;
      l_buffer VARCHAR2(32767);
      l_amount BINARY_INTEGER := 32565;
      l_pos INTEGER := 1;
      l_lengte number;
      l_lineCount number := 0;
    BEGIN
      l_clob := rpad( to_clob( 'test' ), 60000, 'test' );
      l_lengte := DBMS_LOB.GETLENGTH (l_clob);
    DBMS_OUTPUT.PUT_LINE('lengte clob veld: ' || l_lengte);
      l_file := UTL_FILE.fopen( 'MY_DIR', 'Sample1.txt', 'wb', 32767 );
      LOOP
        begin
          DBMS_LOB.read (l_clob, l_amount, l_pos, l_buffer);
        exception
          when no_data_found then exit;
        end;
    --    UTL_FILE.PUT_RAW( l_file, utl_raw.cast_to_raw( l_buffer ) ); -- file in database character set
        UTL_FILE.PUT_RAW( l_file, utl_i18n.string_to_raw( l_buffer, 'WE8MSWIN1252' ) );
        l_pos := l_pos + l_amount;
    DBMS_OUTPUT.PUT_LINE('Offset position: ' || l_pos);
      END LOOP;
      UTL_FILE.fclose(l_file);
    END;Anton

  • Using Oracle Text with CLOB field containing multiple languages

    I'm using Oracle 10g (NLS_CHARACTERSET is set to. AL32UTF8) and have a table with a CLOB field which is storing text written in either English and/or Simplified Chinese.
    The following index has been created on this field:
    CREATE INDEX text_index
    ON text_table(text_field)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS('FILTER CTXSYS.INSO_FILTER');
    I'm having issues in returning text which matches the Chinese text using the CONTAINS operator. For some reason the following query is returning rows which do not contain any Chinese text:
    SELECT *
    FROM text_table
    WHERE contains(text_field,'炫%') > 1;
    A newsgroup user advised me to produce an explain plan using ctx_query.explain.
    I created 2 explain plans, one which was searching the index for 'A%' and the other searching for the Simplified Chinese character '炫%'. The results for the first test were as expected whereby the values contained within the OBJECT_NAME field all began with the letter 'A'.
    The second test however produced somewhat unexpected results. The OBJECT_NAME field this time contained various words, both English and Simplified Chinese. I could be wrong but it appeared to store every individual word in the CLOB field. Both tests produced different EQUIVALENCE rows, the first test was:
    OPTIONS = Null
    OBJECT_NAME = A%
    Whereas the second test produced:
    OPTIONS = (?)
    OBJECT_NAME = %
    Am I right in thinking the Simplified Chinese character is for some reason being converted to a '?' character?
    Any help on this will be much appreciated.

    As you're not specifying a lexer to use, it will use the BASIC_LEXER, designed for space-separated European-type languages. This won't work effectively with Chinese.
    If you know which documents are Chinese and which are English, you can write this into a LANGUAGE column and use the MULTI_LEXER - this will allow you to specify BASIC_LEXER for the English texts, and CHINESE_LEXER or CHINESE_VGRAM_LEXER for the Chinese texts.
    If you don't know the language, you must use either WORLD_LEXER (10g) or AUTO_LEXER (11g). These lexers will automatically determine the language of the documents and index them appropriately. In general. MULTI_LEXER will be faster and more accurate than either of the automatic alternatives.
    When querying for Chinese characters you need to be very careful with your NLS_LANG settings. You need to make sure that the character set defined in NLS_LANG is the same as the character set from which you've pasted (or typed) the chinese characters.
    The "?" in output usually just means "I don't know how to translate this character into your output character set". Sometimes it may appear as a reversed question mark.

  • How do I set a maximum length (in characters) of a CLOB field

    Hi,
    I've seen some questions like this around, but I did not find a clear answer.
    This is my problem: I want to make my CLOB field to accept a maximum of 32768 characters. This is because I need other data manipulation tools to receive an ORA error when they try to insert or update text larger than 32768.
    I tried with an Insert/Update trigger, but I received ORA error that actually means that LOB fields can not be used in update trigger(or something).
    Please, help!

    Maybe, Not a neat way to do things, but seems to work.
    Others may be able to suggest better solutions.
    SQL> create table test_lob(lob clob) ;
    Table created.
    SQL> CREATE OR REPLACE FUNCTION getlength(p_lob CLOB) RETURN NUMBER DETERMINISTIC IS
      2  BEGIN
      3      IF (dbms_lob.getlength(p_lob) > 32768)
      4      THEN
      5          raise_application_error(-20100,
      6                                  'Text may not be greater than 32768 characters!');
      7      ELSE
      8          RETURN NULL;
      9      END IF;
    10  END;
    11  /
    Function created.
    SQL> create index idx_test_lob on test_lob(getlength(lob)) ;
    Index created.
    SQL>
    SQL> declare
      2    l_lob CLOB ;
      3  begin
      4    insert into test_lob values (empty_clob()) returning lob into l_lob ;
      5    dbms_lob.writeappend(l_lob, 32767, rpad('*', 32767, '*')) ;
      6  end ;
      7  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2    l_lob CLOB ;
      3  begin
      4    insert into test_lob values (empty_clob()) returning lob into l_lob ;
      5    dbms_lob.writeappend(l_lob, 32760, rpad('*', 32760, '*')) ;
      6    dbms_lob.writeappend(l_lob, 8, rpad('*', 8, '*')) ;
      7  end ;
      8  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2    l_lob CLOB ;
      3  begin
      4    insert into test_lob values (empty_clob()) returning lob into l_lob ;
      5    dbms_lob.writeappend(l_lob, 32760, rpad('*', 32760, '*')) ;
      6    dbms_lob.writeappend(l_lob, 9, rpad('*', 9, '*')) ;
      7  end ;
      8  /
    declare
    ERROR at line 1:
    ORA-20100:
    ORA-06512: at "SYS.DBMS_LOB", line 789
    ORA-06512: at line 6
    SQL> select count(*) from test_lob ;
      COUNT(*)
             2
    1 row selected.
    SQL>

Maybe you are looking for

  • ESATA external hard drive woes under Bootcamp

    Hi everyone, I have just taken delivery of a early 2009 MBPro 17 inch and a WD MyBook USB/eSATA/Firewire external HD. I am trying to use the MyBook with eSATA in bootcamp with a generic expresscard that utilises the Silcon Image Sil3132 chip. I'm onl

  • Vendor requirement in RFQ (ME41)

    Good day, everyone! Here's the scenario: we want to create a dummy RFQ without a vendor. But the system does not allow saving it because it requires a vendor. I already deactivated the vendor requirement in "Define Screen Layout at Document Level" bu

  • Help resolve please

    Hi all, Please can anyone help with resolving the errors below? SQL> shutdown abort ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 118255568 bytes Fixed Size 282576 bytes Variable Size 83886080 bytes D

  • TS1398 The only problem I have is why would my iOS device (iPhone 4s) stop being compatible with my older third-party router after a software upgrade?

    I think it's a driver issue not a hardware issue, I can use wifi at work just not at home... I have an iPhone 4s and it seems to connect to the wifi where I work without any problems.  I cannot connect to my wifi at home even after turning off encryp

  • Sync to Asyn Message interface mapping

    Hi all, I have a scenario where source message interface is a sync interface and target is async. Can any body suggest if it is possible to map the request message structure of source to target (async) and the response need to have a fixed value. Is