TO_DATE function with JPA, Getting Unexpected Token error

I am constructing a search query like this from my JAVA code
SELECT * FROM EMAIL_PROXY_ERROR_LOG WHERE (to_date((REPLACE (DATETIME,'T',':')),'yyyy-mm-dd:hh24:mi:ss') BETWEEN to_date('2008-04-29:11:30:08','yyyy-mm-dd:hh24:mi:ss') AND to_date('2008-04-30:11:30:02','yyyy-mm-dd:hh24:mi:ss'))
I am using Toplink Essentials and I get the following error while running, what would be a possible solution
Exception Description: Syntax error parsing the query [select c FROM EmailProxyErrorLog c WHERE to_date((REPLACE (c.dateTime,'T',':')),'yyyy-mm-dd:hh24:mi:ss') BETWEEN to_date('2008-04-26:11:30:08','yyyy-mm-dd:hh24:mi:ss') AND to_date('2008-04-30:11:30:02','yyyy-mm-dd:hh24:mi:ss')], line 1, column 42: unexpected token [to_date].
Internal Exception: line 1:42: unexpected token: to_date
at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.handleANTLRException(EJBQLParser.java:350)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:278)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.reportError(EJBQLParser.java:378)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticPrimary(EJBQLParser.java:3617)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticFactor(EJBQLParser.java:3513)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticTerm(EJBQLParser.java:3407)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.simpleArithmeticExpression(EJBQLParser.java:1021)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticExpression(EJBQLParser.java:2304)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.simpleConditionalExpression(EJBQLParser.java:2282)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalPrimary(EJBQLParser.java:2218)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalFactor(EJBQLParser.java:2155)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalTerm(EJBQLParser.java:2030)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalExpression(EJBQLParser.java:1989)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.whereClause(EJBQLParser.java:507)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectStatement(EJBQLParser.java:184)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:135)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:166)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:127)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:215)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:114)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99)
at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:86)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204)
Caused by: line 1:42: unexpected token: to_date
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticPrimary(EJBQLParser.java:3611)

Hello,
The JPQL dies not define a to_date function, which is why it will throw an exception when parsing the query string. You will need to use a native query for this if you need to convert database fields to dates for comparison.
Best Regards,
Chris

Similar Messages

  • Unexpected Token: Error occuring inside a stored procedure

    I get an unexpected token error when trying to compile below stored procedure. The error occurs on the exec pk_proof.pr_ProofAssets execution statement inside the stored procedure. Any reason why?
    CREATE OR REPLACE PROCEDURE MONTHLY_ASSET (ln_business_dt_num IN NUMBER DEFAULT NULL,
                                               missing_tbl_name OUT NOCOPY VARCHAR2)
    IS
       ln_business_dt_num NUMBER;
       missing_tbl_name VARCHAR2;
       no_tbl_name_found EXCEPTION;
       bad_date_value EXCEPTION;
       counts_not_matched EXCEPTION;
    BEGIN
       IF ln_business_dt_num < 0 THEN
       RAISE bad_date_value;
       ELSE
         Select MAX(business_dt_num) into ln_business_dt_num
         FROM sasor.dp_ca_proof;
       if missing_tbl_name IS NOT NULL then
          raise no_tbl_name_found;
       end if;
       exec pk_proof.pr_ProofAssets('SLH_DST_ASSET', ln_business_dt_num, 'sasor_batch');

    EXEC (short for EXECUTE) is an SQL*Plus command. Just remove it.

  • Unexpected Token error in CS4 64-bit plugin

    Hi All,
    I want to migrate my photoshop CS4 plugin from 32bit to 64 bit environment.
    Here is the code chunk i have added in the .r file for the 64bit recompile:
    #if defined(_WIN64)
    CodeWin64X86 { "PluginMain" },
    #else
    CodeWin32X86 { "PluginMain" },
    #endif
    I am getting the following error in the .r file while compilation.
    Unexpected token ('CodeWin64X86 { "PluginMain" },'
    I have done all the settings required for 64bit in the project settings:
    Like In C/C++:
    - Detect 64-bit portibility issues = Yes
    In Linker:
    - Advance->TargetMachine = MACHINEX64
    I do not understand what else is missing.. Can anybody has any idea what
    is going wrong.
    Please help me.
    Regards
    Hemant

    Are you using the cnvtpipl.exe that came with the CS4 SDK?
    Older versions won't recognize the new properties.

  • Unexpected Token Error

    Hi,
    --> I am using JBoss 3.0.2
    --> have succesfully deployed my beans
    --> client to server communication is happening
    But when a method in my session bean is calling a finder method on an entity bean i get the following error
    14:23:02,781 ERROR [STDERR] Caused by: javax.ejb.EJBException: Load failed; Caus
    edByException is:
    Unexpected token: FROM in statement [SELECT name,count FROM ENTITY WHERE
    (name='david') OR (name='mandy') OR (name='bush') OR (name='clinton') OR (name=
    'arun')]
    14:23:02,781 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntity
    Command.execute(JDBCLoadEntityCommand.java:176)
    14:23:02,781 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntity
    Command.execute(JDBCLoadEntityCommand.java:62)
    14:23:02,781 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManag
    er.loadEntity(JDBCStoreManager.java:572)
    what might be the reason ?
    Thanks in advance
    Meka Toka

    The problem is that count is a reserved word. It's expecting, count(some_column_name) or count(*).
    Paul

  • Could not retrieve the doc with the passed obsolete token(Error: RWI 00323)

    Error using WebService API via Tomcat and .NET framework 2.0. Am storing ReportEngine and Session instance memory as suggested but still get this error. How can I reset tokens or increase token limit so this error does not occur.
    Inner Exception
    Type : BusinessObjects.DSWS.DSWSException, BusinessObjects.DSWS, Version=11.5.4100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
    Message : getDocumentInformation exception (Error: RWI 00323)
    Source : DSWS Web Service Consumer
    Help link :
    ID : R1
    WebServiceID :
    Operation : reportengine.dsws.businessobjects.com/getDocumentInformation
    CallStackTrace : com.businessobjects.rebean.wi.ConfigurationException: Could not retrieve the document with the passed obsolete token. (Error: RWI 00323)
    at com.businessobjects.rebean.wi.ReportEngineImpl.getDocumentFromStorageToken(ReportEngineImpl.java:461)
    at com.businessobjects.rebean.wi.occa.WebiReportEngine.getDocumentFromStorageToken(WebiReportEngine.java:239)
    at com.businessobjects.dsws.WebIntelligenceReportEngineManager.openDocument(Unknown Source)
    at com.businessobjects.dsws.wsb.reportengine.WebIntelligenceReportEngineSoapImpl.getDocumentInformation(Unknown Source)
    at com.businessobjects.dsws.reportengine.ReportEngineSoapImpl.getDocumentInformation(Unknown Source)
    at com.businessobjects.dsws.reportengine.ReportEngineSoapSkeleton.getDocumentInformation(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor166.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:402)
    at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:309)
    at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:333)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
    at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:481)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:323)
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:854)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at com.businessobjects.dsws.wsc.common.axis.FlashFilter.doFilter(Unknown Source)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: com.businessobjects.rebean.internal.util.storage.InternalStorageException: token:we00100000e9816b1c411b is probably too old, could not be found in token history...
    at com.businessobjects.rebean.internal.util.storage.ClusterStorageManager.retrieveObject(ClusterStorageManager.java:380)
    at com.businessobjects.rebean.wi.ReportEngineImpl.getDocumentFromStorageToken(ReportEngineImpl.java:449)
    ... 47 more
    CauseID : RWI 00323
    CauseMessage : Could not retrieve the document with the passed obsolete token. (Error: RWI 00323)
    CauseDetail :
    CauseException : com.businessobjects.rebean.wi.ConfigurationException
    Data : System.Collections.ListDictionaryInternal
    TargetSite : BusinessObjects.DSWS.ReportEngine.DocumentInformation GetDocumentInformation(System.String, BusinessObjects.DSWS.ReportEngine.RetrieveMustFillInfo, BusinessObjects.DSWS.ReportEngine.Action[], BusinessObjects.DSWS.ReportEngine.Navigate, BusinessObjects.DSWS.ReportEngine.RetrieveData)
    Stack Trace : at BusinessObjects.DSWS.ReportEngine.ReportEngine.GetDocumentInformation(String documentReference, RetrieveMustFillInfo retrieveMustFillInfo, Action[] actions, Navigate navigate, RetrieveData retrieveData)
    Thanks

    You can reclaim storage token stack space by sending Close action to any document you're done with.
    You can increase the storage token stack space by editing the Web Services Provider app dswsbobje.war, the file WEB-INF\classes\webi.properties.  Look inside that file for the storaget token stack size setting.
    Sincerely,
    Ted Ueda

  • Can't install add-ins. Get unexpected installation error. Console has this

    I get this error in the console:
    Error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsILocalFile.persistentDescriptor]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///Applications/Firefox.app/Contents/MacOS/components/nsExtensionManager.js :: getAbsoluteDescriptor :: line 406" data: no]
    Source File: file:///Applications/Firefox.app/Contents/MacOS/components/nsExtensionManager.js
    Line: 406

    For details about how to resolve this see the [[unexpected installation error -203 when installing add-ons]] article.

  • Using = with to_date function fails to get the results

    Hello ALl,
    I have table for visits information. my table has two fields survey_id (Number) and visit_date(date).
    the visit_date also contain the visit time HH:MI:SS.
    when I query the table to find the information for one day and using the following qyery:
    select survey_id,visit_date
    from my_table
    where visit_date=to_date('26/04/2010','DD/MM/YYYY');
    The result is no data found
    but When I used another query such as
    select survey_id,visit_date
    from my_table
    where visit_date>to_date('25/04/2010','DD/MM/YYYY');
    there are some records in date 26/04/2010.
    In other words, always when I query the table for one day using
    visit_date=to_date(:my_date,'DD/MM/YYYY');
    there is no data returned although there is data in the table.
    is the problem because the time HH:MI:SS exisits in visit_date field.
    any help please.
    Edited by: M.Jabr on May 5, 2010 6:12 AM

    Oracle stores dates as a numeric (I think 9 digit) format which includes the time.
    When you use the = operator with a truncated string, it assumes zeros for the time elements.
    So your first query is looking for visits which were at exactly midnight.
    So your options are to use the trunc function as suggested or to use the 'between' syntax.

  • Getting unexpected 3338 errors when your DRM policy is set to USE_IF_AVAILABLE?

    [ Background ]
    A popular restriction to set in an Adobe Access DRM policy deals with Output Protection - where playback of a content is disallowed unless the device's hardware can support Copy Protection technologies, such as HDCP or CGMS-A.
    A possible Output Restriction setting to set is "USE_IF_AVAILABLE".  When a license with this restriction is consumed by a device, the device will first check to see if an Output Protection technology is available, like HDCP, and if available - attempt to engage it before playing the content.  Regardless on if the Output Protection technology is available, playback of the content will always occur, since "USE_IF_AVAILABLE" is considered a best-effort enforcement.
    [ Problem Which Existed Prior to Flash Player 11.8.800.168 ]
    Sometimes, when "USE_IF_AVAILABLE" was used as the Output Protection policy setting, the Flash Player client would return an highly-intermittent "3338" error event and prevent video playback.  An attempt to re-play the content resolves the issue.  This does not affect other runtimes supported by Adobe Access, such as iOS or Android.
    [ Resolution ]
    2. (End User) Upgrade to Flash Player 11.8.800.168 or later, where this issue has been addressed.
    1. (Video Player Application Developer) If your business/contractual rules don't require Output Protection to be enabled (even on a best-effort basis), consider changing the Output Protection restriction to NO_PROTECTION.  Setting NO_PROTECTION instructs Adobe Access DRM to not even attempt to detect if Output Protection is available, preventing this OS error to even occur.
    [ Problem Not Resolved? ]
    This article details what Adobe believes will resolve 3338 errors from occuring when the DRM policy has only set USE_IF_AVAILABLE for analog or digital output channel.  If this hasn't resolved your issue - we would love to hear more from you!  Please reply below with the following information:
    - Your manifestation of the problem
    - The policy you used during packaging
    - OS & OS version this was observed on
    - Browser & browser version this was observed on
    - (Video Player Application Developer) The SWF version of your video player application
    cheers,
    /Eric.

    Hi ,
    1.Please empty the auto complete cache in outlook and try sending the email by manually typing the user email address on the to field while composing the new message.
    2.Please ensure the AD replication is working properly.
    3.Then use the below mentioned command to check the recipient is available in your exchange or not.
    get-recipient -identity "[email protected]" | ft -au
    4.Make sure you are running your outlook in online mode.
    5.Please update the GAL manually.
    6.In case if you want have the outlook in cached mode , you need to have updated OAB in outlook client.
    Regards
    S.Nithyanandham
    Thanks & Regards S.Nithyanandham

  • How to use SQL String functions with JPA and SAP NW

    Hi Everyone,
    I'm recently got the following problem:
    I have a Web Service project using JPA. But as i found out SAPs JPA implementation or more precisely openSQL restricts the use of the LOWER() function, which converts a String to lower case.
    Now I am looking for some sort of workaround. I want to execute the following JPQL query:
    SELECT bp FROM BusinessPartner bp WHERE LOWER(bp.companyName) LIKE LOWER(:companyName)
    I assume there is somewhere a flag to disable this restrictions, because there might be cases, like mine, where this standard functions are needed.
    Kind Regards,
    Carl

    Hi Vladimir,
    no it's not the same issue, because I am asking for a solution for this problem. There have to be ways to bypass this. Otherwise you can't use JPA properly. This is too much of a restriction!
    Is there no possibility to change to another implementation than openSQL?
    Regards,
    Carl
    Edited by: Carl Simon Heckmann on Feb 2, 2009 2:26 PM

  • Could not retrieve the document with the passed obsolete token.

    Hi,
    Issue is with the specific report not able to execute when the query is cancelled and getting an error when you are cancelling an already executing query.
    Receiving an error message during running one of our report in the
    following way:
    - Run the Webi report
    - Select the value for 8 prompts
    - Click on cancel
    - try to re-run by clicking on re-fresh and receive an error message.
    The error message is the following:
    "Could not retrieve the document with the passed obsolete token (Error: RWI 00323) (Error: INF)"
    Till now we have made the following changes:
    This might be caused by a storage token that identifies a document state, which is no longer available in the storage tokens stack.
    In the webi.properties file, increased the value of storage tokens stack size.
    1. Edit the webi.properties file found in the following location:
    u2022 <Installed dir>\program files\businessobjects\BOenterprise115\Web services\en\dsws_webservice_boe\data\asemble\dsewsBobjJava\src\WEB-INF\classes\webi.properties.
    2. Add or change the following variables:
    u2022 WID_FAILOVER_SIZE (This sets the maximum number of tokens to keep in memory. It is 10 by default.)
    u2022 WID_STORAGE_TOKEN_STACK_SIZE (this sets the maximum number of tokens stored on disk. It is 10 by default.)
    u2022     Deleted cookies.
    u2022     Add  the Java Runtime Parameter value from following path:
    Start - > Control Panel-> Java -> Java Applet Runtime Settings
    Click on View.
    Add the Java runtime Parameter value: Xmx200.
    It is not a machine specific issue however it is intermittent.
    Please advice.
    Regards,
    Pradnya Kokil

    Hi Pradnya,
    Following solutions might help you to resolve the issue.
    Solution1:
    To achieve optimum performance, the developer should limit the number of new windows that can be opened using the OpenDocument function, particularly if using it within the drill function.
    If you must open a new window each time, you can increase the number of document instances available on the system by modifying parameters in the webi.properties file:
    1. On the Business Objects server, navigate to the following directory:
    C:\Program Files\Business Objects\Tomcat\webapps\businessobjects\enterprise115\desktoplaunch\WEB-INF\classes
    2. Open the webi.properties file using a text editor.
    3. Uncomment the FAILOVER_SIZE=10 line by removing the # from the beginning of the line.
    4. After FAILOVER_SIZE, add the following:
    STORAGE_TOKEN_STACK_SIZE=40
    5. Save the file.
    6. Restart the application server
    Solution2:
    Do not use Control Key + N or File New from Browser for invoking new instance of Browser
    Avoid opening Infoview by Hyperlinks.
    Alternatively, by setting logontoken.enabled property in web.xml for desktop.war, will stop users allowing using old token
    Locate web.xml file in desktop.war file deployed on your application server
    Locate the following string in web.xml:<param-name>logontoken.enabled</param-name>
    Change the <param-value> for logontoken.enabled from true to false (forexample, <param-value>false</param-value>)
    Save and close the file
    Restart the web application server to apply the changes
    Regards,
    Sarbhjeet Kaur

  • Mapping aborts instead of records getting audited in error tables

    We have several instances when a mapping encounters an invalid number error (source is non-numeric and target is numeric) and the mapping aborts with a "Invalid number" error, instead of the error being logged in the wb_rt_error* tables, and the mapping continuing. The max number of errors is set to 10,000 or something, so that is not an issue. In other instances, it does continue with warning as expected.
    I can't seem to find a pattern with this. Can someone tell me why OWB behaves like this? Is there an explaination to this? We really don't want our mappings killed by bad source data. We sould like OWB to complain, log the error, and continue.
    Please help.
    -Whiskeylover

    It sounds as though there is some specific type of data error which is occurring occassionally, and which OWB is not handling properly. As you point out, sometimes OWB does log and move on - sometimes it doesn't. The hard part is going to be figuring out what the exact data is that is causing the problem and resolving it.
    On the next day when this happens, in the prod environment run something like:
    declare
       cursor get_vals is
         select the_problem_field from the_source_table;
       function validate_field (invar in varchar2)
       return 0
       is
         testnum number;
       begin
         testnum := to_number(invar);
       exception
          when others then return 1;
       end;
    begin
        for source_record in get_vals
        loop
           if validate_field(source_record.the_problem_field) = 1 then
               dbms_output.put_line(source_record.the_problem_field);
           end if;
        end;
    end;
    /This will give you the list of values which would fail the to_number, and you can try looking for anything extraordinary, or use it as a test sample to run through another mapping.
    OH!!!! Wait!
    Just had a thought.
    If the query that is generating the data for the query is doing any formatting, then it could be the cursor that is failing and not the insert. In that case the cursor fails and exits as it cannot continue which would result in the circumstance you are describing. The error audit counting only works if the problem is at the insert portion of the code - not the select.
    Open the mapping package body and pull the cursor out. If there is a to_number() or other function being applied against the source field then this almost certainly your problem.
    You would be able to test this with a simple query by running a select with that function against the source table to see if it errors.
    Case in point:
    assume a varchar field that you are converting to date. You have desinged the mapping to use a to_Date() function with a format mask according to what should be in the field: e.g. to_date(the_field, 'yyyyymmdd'), and there is a singe record with the value '2009081111'. The select fails and will not process subsequent rows.
    I would bet that this sort of thing is your issue.
    Oh, and this error could be coming from any of the fields if you are getting a non-specific error - not neccessarily the field that you think is the problem.
    Cheers,
    Mike

  • How to use quarter format in "to_date()" function?

    Hi,
    I'm trying to use to_date() function with quarter format. How do I specify the format?
    For example to convert '2002 quarter 1' using the to_date function.
    I tried to_date('20021', 'YYYYQ'), and I got ORA-01820 cannot appear in date input format.
    Please help, thank you!!!

    You cannot use Q when inputting data, only when retrieving data. When inputting, you must enter a valid date. Oracle has to store a date and if you just enter a quarter, it can't figure out what date to store. See the examples below:
    SQL> -- test table:
    SQL> CREATE TABLE test_table
      2    (test_date DATE)
      3  /
    Table created.
    SQL> -- the wrong way to input:
    SQL> INSERT INTO test_table (test_date)
      2  VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
      3  /
    VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
    ERROR at line 2:
    ORA-01820: format code cannot appear in date input format
    SQL> -- the right way to input:
    SQL> INSERT INTO test_table (test_date)
      2  VALUES (TO_DATE ('27-OCT-2002', 'DD-MON-YYYY'))
      3  /
    1 row created.
    SQL> -- to output:
    SQL> COLUMN "Year and Quarter" FORMAT A16
    SQL> SELECT test_date,
      2         TO_CHAR (test_date, 'YYYY-Q') AS "Year and Quarter"
      3  FROM   test_table
      4  /
    TEST_DATE   Year and Quarter
    27-OCT-2002 2002-4
    1 row selected.

  • To_Date Function Question

    I am trying to update an Oracle table date column without success. My SQL string is "UPDATE mytable SET trans_date = " & now() & where order_id = " & user_text
    Oracle does not like now(). I found a function TO_DATE() but I get the message "Name 'to_date' is not declared."
    How would I go about sending the date to update Oracle 10g. I have installed
    Oracle Developer Tools for Visual Studio .NET 10.2.0.2.20.
    Any help is greatly appreciated.
    Thank you,
    Fred

    Hi Fred,
    Dealing with dates can sometimes be tricky.
    I would firstly advise to use bind variables (aka parameters) rather than "gluing" values into the statement. Here's a link to an older article I did for Oracle Magazine that discusses bind variables:
    http://www.oracle.com/technology/oramag/oracle/05-sep/o55odpnet.html
    If you use bind variables one method to update a date would be similar to:
    // create an oracle command object to use for sample
    OracleCommand cmd = con.CreateCommand();
    cmd.CommandText = "update test set date_column = :1";
    // create date object representing current time on client
    OracleDate d = new OracleDate(DateTime.Now);
    // create parameter object to use for insert
    OracleParameter p_date = new OracleParameter();
    p_date.OracleDbType = OracleDbType.Date;
    p_date.Value = d;
    // add parameter for the date
    cmd.Parameters.Add(p_date);
    // insert the date
    cmd.ExecuteNonQuery();If you do glue the value into the sql (again, I do not recommend this), you would use the to_date function with a character string representation of the date and the date format string. Something like:
    ... to_date('12/31/2007', 'MM/DD/YYYY') ...
    Also, if you are not familiar with dates in Oracle they also hold the time value as well. Something to keep in mind.
    Hope that helps a bit,
    Mark

  • Using AGO function with partitions

    I have a situation where we have logical sources with the same repository folder that are partitioned. We would like to use the AGO function but are getting the following error:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 22042] AGO function may not be used on '# Applied Invoices' because its source is horizontally partitioned. (HY000)
    Has anyone had success using the AGO function with partitions? If not, do you have an alternate solution to the problem?

    AGO doesn't work with partitions - it's documented on metalink....there's an enhancement request , but that's it - no work-around provided....I'd suggest creating a common view for that particular report

  • Getting "Unexpected end of formula" error in user-defined function

    I created a user-defined function and registered it successfully in Discoverer Admin (10g), and it shows up in Discoverer Plus. However, when I call the function, I get this error:
    "Error in formula -- unexpected end of formula"
    If I hard-code in parameters, I can successfully run the function as such from Oracle SQL Developer:
    SELECT PAYLINETOT('2324', '111', to_date('01-Sep-2010'), to_date('31-Oct-2010'))
    FROM DUAL;
    But I still get the same error if I enter this in the calculation dialog in Discoverer:
    PAYLINETOT('2324', '111', to_date('01-Sep-2010'), to_date('31-Oct-2010'))
    Any idea what's going on and how to get this to work?

    Michael,
    I tried your suggestion, and this time I got a different error message that said that the function had not been registered with the EUL. I thought I had registered it, but when I checked, the return data type was wrong. I corrected it, and the function is "valid" in Discoverer Admin. Yet, when I go back to Discoverer Plus and attempt to use the function (and yes, I logged out and logged back in), I get the same error message:
    "Error in formula - unexpected end of formula - Error: Function PAYLINETOT has not been registered with the EUL."
    Any idea where the disconnect is? Are these two separate errors? How could Discoverer Admin tell me that the function is registered and Discoverer Plus tell me otherwise? And yes, I've made sure that the "Available in Desktop/Plus" checkbox is checked.

Maybe you are looking for

  • After updating to latest version, Firefox won't open

    I am running Windows 7. After updating to the latest version, Firefox won't open. I get a notice when I try to open Firefox saying "Couldn't load XPCOM. Is there a way I can undo the update so I can get Firefox to open. It's my favorite browser...I'm

  • Total mess trying to sync iTunes playlists to my iPhone 5

    Hi. So I'm trying to get just certain playlists from my Mac to my iPhone 5.  But I'd settle for just copying the whole library.  When I try the former, I get 87 out of nearly 600 songs from my main playlist, and I get all my wife's country songs that

  • IMac 24" Display VERY BRIGHT!

    Okay, I know this is not the first time someone has complained about the monitors being too bright, but here I am. I am a new owner of the 24" iMac, and I love the size, but it's TOO BRIGHT! Is there anything I can do that can lower the brightness lo

  • Loading AP image from ROMMON

    After setting the IP address, mask and gateway on the AP while in ROMMON, shouldn't the AP be reachable by PING? I have a couple of APs, 1142 and 3502 that can't boot and report the image on the flash is corrupted.   The steps are straightforward to

  • How to recover IWork Numbers image

    I have accidentally deleted the original start page/icon for the Numbers application - the blue image that opens up first thing on clicking the Numbers application, and shoul be tapped to go to templates. I have restored the original iPad settings, b