Date column is throwing error in my query.

select (to_date(((to_char(to_date('6/27/1980','mm/dd/rrrr'),'DD/MM'))||'/' ||
((to_char(sysdate,'rrrr'))- (to_char(to_date('6/27/1980','mm/dd/rrrr'),'rrrr'))
+(to_char(to_date('6/27/1980','mm/dd/rrrr'),'rrrr')))),'DD/MM/yyyy')) current_dob from M_CUSTOMER_HDR
This query is working.
select (to_date(((to_char(to_date(cust_Dob,'mm/dd/rrrr'),'DD/MM'))||'/' ||
((to_char(sysdate,'rrrr'))- (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr'))
+(to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr')))),'DD/MM/yyyy')) current_dob from M_CUSTOMER_HDR
This query is getting error:-
a non-numeric character was found where a numeric was expected
all data in table is following same date formate.but null values are also available in column.
can any body help me in this query. thanks in advance..

Null gives the problem:
SQL> with M_CUSTOMER_HDR as (
  2  --  select '6/27/1980' as cust_dob from dual
  3    select null as cust_dob from dual
  4  )
  5  select (
  6    to_date(
  7      (
  8        (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'DD/MM'))
  9        ||'/' ||
10        (
11          (to_char(sysdate,'rrrr'))
12          - (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr'))
13          + (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr'))
14        )
15      )
16      ,'DD/MM/yyyy'
17    )) current_dob
18  from M_CUSTOMER_HDR
19  ;
      ||'/' ||
ERROR at line 9:
ORA-01858: a non-numeric character was found where a numeric was expected
SQL> with M_CUSTOMER_HDR as (
  2  --  select '6/27/1980' as cust_dob from dual
  3    select null as cust_dob from dual
  4  )
  5  select --(
  6  --  to_date(
  7      (
  8        (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'DD/MM'))
  9        ||'/' ||
10        (
11          (to_char(sysdate,'rrrr'))
12          - (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr'))
13          + (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr'))
14        )
15      )
16  --    ,'DD/MM/yyyy'
17  --  )) current_dob
18  from M_CUSTOMER_HDR
19  ;
((TO_CHAR(TO_DATE(CUST_DOB,'MM/DD/RRRR'),'DD/M
/'/' is not a date in 'DD/MM/YYYY' format ;).
Note also that expression "- (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr')) + (to_char(to_date(cust_Dob,'mm/dd/rrrr'),'rrrr'))" is always evaluates to 0 (or null if cust_dob is null).
Regards,
Dima

Similar Messages

  • Count() function throws error in EQL query for metric

    Hi
    I am trying to use count function in EQL query for Metric Bar to show the number of occurrences of a record.
    When the record type doesn't exist i expect the function to return count as 0. Instead the function throws a runtime exception and the whole Metric Bar portlet fails, with error No Results Available. Even though other components in the metric bar have valid results.
    2013-02-21 13:03:51,216 WARN [MetricsBarQueryProcessor] The EQL query does not return any results.
    2013-02-21 13:03:51,216 ERROR [MetricsBarQueryProcessor] The EQL query does not return any results.
    2013-02-21 13:03:51,216 WARN [MetricsBarResultsProcessor] No statement results to process.
    The EQL query i am using is
    RETURN NUMBER_OCCURS AS SELECT COUNT(EMP_ID) AS NUMBER_OCCURS where EMP_NAME IS NOT NULL group;
    I tried using COALESCE but that doesn't help.
    Can some one please suggest a workaround to this?

    Srikanth,
    Two statements are used here because the original question was pertaining to the null set (where there are employees in the nav state but no employees that fit the special analytics criteria in the navigation state). The question/answer has nothing to do with what is in the COUNT parentheses clause as Counting a null set will always give you NULL, not 0, no matter what you put in there.
    What we're really doing, in the second part of the query, is writing a query over a set of data that is not the null set (i.e. the current navigation state). This allows the 0 value to come through in the case where the first analytics statement is evaluated over a null set of records. If there were truly no records in the navigation state, this too would return a null set and not zero.
    Hope that makes sense, feel free to respond (either on here or offline) if it's unclear.
    Regards,
    Patrick Rafferty
    http://branchbird.com

  • Shared-library in OC4J - load data-sources.xml throws error

    H
    To share common libraries (framework.jar, JAXB jars, axis.jar, log4j, tibco*.jars)
    across application(app1/app2/app3) in the OC4J container.
    Currently all these jars are loaded with common jars separately application, a total 3 common
    footprints of these jars.
    1 - Placed all common jars under $J2EE_HOME/shared-lib folder, updated server.xml in $J2EE_HOME/config.
    2 - Connecting Tibco queues using generic JMS resource adapter (connectors - JCA).
    3 - Connecting to databases using data-sources.xml.
    4 - With following entries in orion-application.xml
    <imported-shared-libraries>
    <import-shared-library name="my.shared.libraries" max-version="1.0"/>
    </imported-shared-libraries> ---> Entry 1
    <connectors path="oc4j-connectors.xml"/> ---> Entry 2
    <data-sources path="data-sources.xml"/> ---> Entry 3
    Getting the following error while deploying the code.
    Error occurred initializing connectors. Exception is: Exception creating Manage
    d DataSource ConnectorPropertySet. Exception: Error setting up resource adapter
    for embedded resource archive inside application 'deployGood1'. ManagedConnecti
    onFactory implementation class 'oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl
    ' cannot be set up: Error setting JavaBean property 'managedDataSourceConfigXML'
    for ManagedConnectionFactory class 'oracle.oc4j.sql.spi.ManagedConnectionFactor
    yImpl for embedded resource archive inside application 'deployGood1'. Exception
    is: java.lang.reflect.InvocationTargetException
    However orion-application.xml
    Option A
    Entry 1 (imported-shared-libraries)
    Entry 2 (connectors)
    Works perfectly fine - however the Service complains of not finding the datasource JNDI
    5 - If all jars are loaded separately with each application
    With following entries in orion-application.xml
    <library path="C:/soft/jar/framework.jar" />
    <library path="C:/soft/jar/log4j-1.2.14.jar" />
    <library path="C:/soft/jar/axis.jar"/>
    <library path="C:/soft/jar/commons-discovery-0.2.jar"/>
    <library path="C:/soft/jar/commons-logging-1.0.4.jar"/>
    <library path="C:/soft/jar/fscontext.jar"/>
    <library path="C:/soft/jar/gjra.jar"/>
    <library path="C:/soft/jar/jax-qname.jar"/>
    <library path="C:/soft/jar/jaxb-api.jar"/>
    <library path="C:/soft/jar/jaxb-impl.jar"/>
    <library path="C:/soft/jar/jaxb-libs.jar"/>
    <library path="C:/soft/jar/jaxb-xjc.jar"/>
    <library path="C:/soft/jar/jaxrpc.jar"/>
    <library path="C:/soft/jar/jmxri.jar"/>
    <library path="C:/soft/jar/jmxtools.jar"/>
    <library path="C:/soft/jar/namespace.jar"/>
    <library path="C:/soft/jar/providerutil.jar"/>
    <library path="C:/soft/jar/relaxngDatatype.jar"/>
    <library path="C:/soft/jar/saaj.jar"/>
    <library path="C:/soft/jar/tibcrypt.jar"/>
    <library path="C:/soft/jar/tibjms.jar"/>
    <library path="C:/soft/jar/tibjmsadmin.jar"/>
    <library path="C:/soft/jar/tibjmsapps.jar"/>
    <library path="C:/soft/jar/tibrvjms.jar"/>
    <library path="C:/soft/jar/wsdl4j-1.5.1.jar"/>
    <library path="C:/soft/jar/wss4j-1.5.2.jar"/>
    <library path="C:/soft/jar/xercesImpl.jar"/>
    <library path="C:/soft/jar/xmlsec-1.4.0.jar"/>
    <library path="C:/soft/jar/xsdlib.jar"/> -------> Entry 1
    <connectors path="oc4j-connectors.xml"/> ---> Entry 2
    <data-sources path="data-sources.xml"/> ---> Entry 3
    This configuration works perfectly fine as expected, but this configuration defeats the
    purpose of shared-library
    Thanks
    sunder

    H
    To share common libraries (framework.jar, JAXB jars, axis.jar, log4j, tibco*.jars)
    across application(app1/app2/app3) in the OC4J container.
    Currently all these jars are loaded with common jars separately application, a total 3 common
    footprints of these jars.
    1 - Placed all common jars under $J2EE_HOME/shared-lib folder, updated server.xml in $J2EE_HOME/config.
    2 - Connecting Tibco queues using generic JMS resource adapter (connectors - JCA).
    3 - Connecting to databases using data-sources.xml.
    4 - With following entries in orion-application.xml
    <imported-shared-libraries>
    <import-shared-library name="my.shared.libraries" max-version="1.0"/>
    </imported-shared-libraries> ---> Entry 1
    <connectors path="oc4j-connectors.xml"/> ---> Entry 2
    <data-sources path="data-sources.xml"/> ---> Entry 3
    Getting the following error while deploying the code.
    Error occurred initializing connectors. Exception is: Exception creating Manage
    d DataSource ConnectorPropertySet. Exception: Error setting up resource adapter
    for embedded resource archive inside application 'deployGood1'. ManagedConnecti
    onFactory implementation class 'oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl
    ' cannot be set up: Error setting JavaBean property 'managedDataSourceConfigXML'
    for ManagedConnectionFactory class 'oracle.oc4j.sql.spi.ManagedConnectionFactor
    yImpl for embedded resource archive inside application 'deployGood1'. Exception
    is: java.lang.reflect.InvocationTargetException
    However orion-application.xml
    Option A
    Entry 1 (imported-shared-libraries)
    Entry 2 (connectors)
    Works perfectly fine - however the Service complains of not finding the datasource JNDI
    5 - If all jars are loaded separately with each application
    With following entries in orion-application.xml
    <library path="C:/soft/jar/framework.jar" />
    <library path="C:/soft/jar/log4j-1.2.14.jar" />
    <library path="C:/soft/jar/axis.jar"/>
    <library path="C:/soft/jar/commons-discovery-0.2.jar"/>
    <library path="C:/soft/jar/commons-logging-1.0.4.jar"/>
    <library path="C:/soft/jar/fscontext.jar"/>
    <library path="C:/soft/jar/gjra.jar"/>
    <library path="C:/soft/jar/jax-qname.jar"/>
    <library path="C:/soft/jar/jaxb-api.jar"/>
    <library path="C:/soft/jar/jaxb-impl.jar"/>
    <library path="C:/soft/jar/jaxb-libs.jar"/>
    <library path="C:/soft/jar/jaxb-xjc.jar"/>
    <library path="C:/soft/jar/jaxrpc.jar"/>
    <library path="C:/soft/jar/jmxri.jar"/>
    <library path="C:/soft/jar/jmxtools.jar"/>
    <library path="C:/soft/jar/namespace.jar"/>
    <library path="C:/soft/jar/providerutil.jar"/>
    <library path="C:/soft/jar/relaxngDatatype.jar"/>
    <library path="C:/soft/jar/saaj.jar"/>
    <library path="C:/soft/jar/tibcrypt.jar"/>
    <library path="C:/soft/jar/tibjms.jar"/>
    <library path="C:/soft/jar/tibjmsadmin.jar"/>
    <library path="C:/soft/jar/tibjmsapps.jar"/>
    <library path="C:/soft/jar/tibrvjms.jar"/>
    <library path="C:/soft/jar/wsdl4j-1.5.1.jar"/>
    <library path="C:/soft/jar/wss4j-1.5.2.jar"/>
    <library path="C:/soft/jar/xercesImpl.jar"/>
    <library path="C:/soft/jar/xmlsec-1.4.0.jar"/>
    <library path="C:/soft/jar/xsdlib.jar"/> -------> Entry 1
    <connectors path="oc4j-connectors.xml"/> ---> Entry 2
    <data-sources path="data-sources.xml"/> ---> Entry 3
    This configuration works perfectly fine as expected, but this configuration defeats the
    purpose of shared-library
    Thanks
    sunder

  • Certain data columns not showing up during a query

    I have having trouble seeing certain data types when I search in Oracle SQL developer. Fields such as Dates and numeric values are showing as blank when I run a query. If I run the same query in SQL Plus, date values and numeric values appear.

    I am using SQL developer 2.1, but this was also happening when I was using early versions such as 1.5.5
    THe Database is an oracle 11g database
    on my machine I have an instance of java 1.5.0_18 running but within the application there is a java 1.6, I am not sure if the 1.6 is executing the program or not.
    WIndows XP service 2002 service pack 3
    Edited by: user9958587 on Jan 7, 2010 3:27 AM
    SELECT * FROM AsAddress which will return our address table containing dates.
    Edited by: user9958587 on Jan 7, 2010 3:27 AM

  • Data source 0RT_PA_TRAN_CONTROL throwing error in RSA7

    Hi Gurs,
    I'm getting the below error while extracting data from data source 0RT_PA_TRAN_CONTROL, in RSA7.
    Update mode "Full Upload" is not supported by the extraction API
    Message no. R3011
    Diagnosis
    The application program for the extraction of the data was called using update mode "Full Upload". However, this is not supported by the InfoSource.
    System Response
    The data extraction is terminated.
    Procedure
    Check for relevant OSS Notes, or send a problem message of your own.
    Your help in this regd. would be highly appreciated.
    Thanks,
    David.

    Step 1 : Go to RSA7 and delete the data source entry from there
    Step 2: Make two infopackages for this datasource, one INIT (without data transfer) and another one Delta ( Full is not supported)
    Step 3: Run the Init. After u do that U should see 0RT_PA_TRAN_CONTROL in RSA7
    Step 4: Now Run the Delta info package
    This shoudl work

  • How to use date column index

    Hi,
    Why is that I got different results for my queries?
    Note that emp_date is indexed, so i dont want to use
    a function to it.
    QUERY1(full table scan)
    SELECT COUNT(*) FROM EMP WHERE TRUNC(EMP_DATE)=TRUNC(SYSDATE-30); (RESULT=8,842)
    QUERY2
    SELECT COUNT(*) FROM EMP WHERE
    EMP_DATE >=(SYSDATE-30) and EMP_DATE < (SYSDATE-30); (RESULT=0)
    QUERY3
    SELECT COUNT(*) FROM EMP WHERE
    EMP_DATE BETWEEN TRUNC(SYSDATE-30) and TRUNC(SYSDATE-30); (RESULT=2,100)
    Please help me how to use indexed date column...

    > Why is that I got different results for my queries?
    Because your queries are different.
    1) This one selects all records on 20 october, regardless of their time component
    2) This one selects all records with an emp_date at least being 20 october 14:56:30 AND being smaller than 20 october 14:56:30. No record will ever satisfy this condition.
    3) This one selects all records on 19./20 october at midnight 00:00:00
    Please see this example:
    SQL> create table myemp (emp_date)
      2  as
      3   select trunc(sysdate) - 30 +
      4          case
      5          when level <= 2100 then 0
      6          when level <= 8842 then dbms_random.value(1,86399)/86400
      7          else 2
      8          end
      9     from dual
    10  connect by level <= 100000
    11  /
    Tabel is aangemaakt.
    SQL> create index i1 on myemp(emp_date)
      2  /
    Index is aangemaakt.
    SQL> exec dbms_stats.gather_table_stats(user,'myemp',cascade=>true)
    PL/SQL-procedure is geslaagd.
    SQL> set autotrace on explain
    SQL> select count(*) from myemp where trunc(emp_date)=trunc(sysdate-30)
      2  /
                                  COUNT(*)
                                      8842
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=88 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (FULL) OF 'MYEMP' (Cost=88 Card=1000 Bytes=
              8000)
    SQL> select count(*) from myemp where
      2  emp_date >=(sysdate-30) and emp_date < (sysdate-30)
      3  /
                                  COUNT(*)
                                         0
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)
    SQL> select count(*) from myemp where
      2  emp_date between trunc(sysdate-30) and trunc(sysdate-30)
      3  /
                                  COUNT(*)
                                      2100
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)
    > Please help me how to use indexed date column...
    Use this query instead:
    SQL> select count(*)
      2    from myemp
      3   where emp_date between trunc(sysdate)-30 and trunc(sysdate)-29 - interval '1' second
      4  /
                                  COUNT(*)
                                      8842
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)Regards,
    Rob.

  • Which type of index is useful for date columns with time stamp

    Hi all,
    I am using date column in the where clause of an SQL Query. The values stored in the date column are includes timestamp. The query is very slow and there is no index on the date column.
    Can any body suggest which index is better on date columns
    Thanks

    I am using date column in the where clause of an SQL Query.Dates a re hard queries to tune. This ...
    WHERE start_date BETWEEN to_date('01-SEP-05') AND to_date('02-SEP-05')...probably requires a very different execution plan to this...
    WHERE start_date BETWEEN to_date('01-JAN-01') AND to_date('02-SEP-05')Just bunging an index on the date column may speed up your specific query but break something else. So be careful.
    Cheers, APC

  • PL/SQL throwing errors! trying to alter dates

    the following code keeps throwing errors, I was wondering if it is due to me getting confused when to use ":" before a variable and also ":=" when setting values?
    Can anyone see what I am doing wrong?
    Here is the code, at the moment it is throwing an error on line 44
    ORA-06550: line 44, column 1:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    CODE.....
    DECLARE
         QNStart DATE;
         QNFinish DATE;
         Q1Start DATE;
         Q1Finish DATE;
         Q2Start DATE;
         Q2Finish DATE;
         Q3Start DATE;
         Q3Finish DATE;
         Q4Start DATE;
         Q4Finish DATE;
         Q5Start DATE;
         Q5Finish DATE;
         QNT NUMBER;
         Q1T NUMBER;
         Q2T NUMBER;
         Q3T NUMBER;
         Q4T NUMBER;
         QNR NUMBER;
         Q1R NUMBER;
         Q2R NUMBER;
         Q3R NUMBER;
         Q4R NUMBER;
    BEGIN
         case current_date
              when current_date between to_date('01-JAN', 'DD-Mon') AND to_date('31-MAR', 'DD-Mon') then
                        QNStart := to_date('01-JAN', 'DD-Mon');
                        QNFinish := to_date('31-MAR', 'DD-Mon');
              when current_date between to_date('01-APR', 'DD-Mon') AND to_date('30-JUN', 'DD-Mon') then
                        QNStart := to_date('01-APR', 'DD-Mon');
                        QNFinish := to_date('30-JUN', 'DD-Mon');
              when current_date between to_date('01-JUL', 'DD-Mon') AND to_date('30-SEP', 'DD-Mon') then
                        QNStart := to_date('01-JUL', 'DD-Mon');
                        QNFinish := to_date('30-SEP', 'DD-Mon');
              when current_date between to_date('01-OCT', 'DD-Mon') AND to_date('31-DEC', 'DD-Mon') then
                        QNStart := to_date('01-OCT', 'DD-Mon');
                        QNFinish := to_date('31-DEC', 'DD-Mon');
         End Case
    :Q1Start := ADD_MONTHS(:QNStart,-3);
    :Q1Finish := ADD_MONTHS(:QNFinish,-3);
    :Q2Start := ADD_MONTHS(:QNStart,-6);
    :Q2Finish := ADD_MONTHS(:QNFinish,-6);
    :Q3Start := ADD_MONTHS(:QNStart,-3);
    :Q3Finish := ADD_MONTHS(:QNFinish,-3);
    :Q4Start := ADD_MONTHS(:QNStart,-4);
    :Q4Finish := ADD_MONTHS(:QNFinish,-4);
    :Q5Start := ADD_MONTHS(:QNStart,-5);
    :Q5Finish := ADD_MONTHS(:QNFinish,-5);
    select COUNT(COUNT(*)) INTO :Q1T from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
    WHERE f.DATE_ENTERED BETWEEN :Q1Start AND :Q1Finish
    AND a.ACTION_SCORE = 'Y'
    AND f.INPUT_TYPE = a.ACTION_NAME
    GROUP BY f.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q2T from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
    WHERE f.DATE_ENTERED BETWEEN :Q2Start AND :Q2Finish
    AND a.ACTION_SCORE = 'Y'
    AND f.INPUT_TYPE = a.ACTION_NAME
    GROUP BY f.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q3T from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
    WHERE f.DATE_ENTERED BETWEEN :Q3Start AND :Q3Finish
    AND a.ACTION_SCORE = 'Y'
    AND f.INPUT_TYPE = a.ACTION_NAME
    GROUP BY f.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q4T from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
    WHERE f.DATE_ENTERED BETWEEN :Q4Start AND :Q4Finish
    AND a.ACTION_SCORE = 'Y'
    AND f.INPUT_TYPE = a.ACTION_NAME
    GROUP BY f.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :QNT from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
    WHERE f.DATE_ENTERED BETWEEN :QNStart AND :QNFinish
    AND a.ACTION_SCORE = 'Y'
    AND f.INPUT_TYPE = a.ACTION_NAME
    GROUP BY f.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q1R from FF_ACTIONS a
    WHERE a.DATE_ENTERED BETWEEN Q1Start AND Q1Finish
    AND a.COMPANY_NAME IN
         (select f.COMPANY_NAME from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
         WHERE f.DATE_ENTERED BETWEEN Q2Start AND Q2Finish
         AND a.ACTION_SCORE = 'Y'
         AND f.INPUT_TYPE = a.ACTION_NAME
         GROUP BY f.COMPANY_NAME)
    GROUP BY a.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q2R from FF_ACTIONS a
    WHERE a.DATE_ENTERED BETWEEN Q2Start AND Q2Finish
    AND a.COMPANY_NAME IN
         (select f.COMPANY_NAME from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
         WHERE f.DATE_ENTERED BETWEEN Q3Start AND Q3Finish
         AND a.ACTION_SCORE = 'Y'
         AND f.INPUT_TYPE = a.ACTION_NAME
         GROUP BY f.COMPANY_NAME)
    GROUP BY a.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q3R from FF_ACTIONS a
    WHERE a.DATE_ENTERED BETWEEN Q3Start AND Q3Finish
    AND a.COMPANY_NAME IN
         (select f.COMPANY_NAME from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
         WHERE f.DATE_ENTERED BETWEEN Q4Start AND Q4Finish
         AND a.ACTION_SCORE = 'Y'
         AND f.INPUT_TYPE = a.ACTION_NAME
         GROUP BY f.COMPANY_NAME)
    GROUP BY a.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :Q4R from FF_ACTIONS a
    WHERE a.DATE_ENTERED BETWEEN Q4Start AND Q4Finish
    AND a.COMPANY_NAME IN
         (select f.COMPANY_NAME from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
         WHERE f.DATE_ENTERED BETWEEN Q5Start AND Q5Finish
         AND a.ACTION_SCORE = 'Y'
         AND f.INPUT_TYPE = a.ACTION_NAME
         GROUP BY f.COMPANY_NAME)
    GROUP BY a.COMPANY_NAME;
    select COUNT(COUNT(*)) INTO :QNR from FF_ACTIONS a
    WHERE a.DATE_ENTERED BETWEEN QNStart AND QNFinish
    AND a.COMPANY_NAME IN
         (select f.COMPANY_NAME from FF_ACTIONS f, FF_ACTION_TYPE_LOV a
         WHERE f.DATE_ENTERED BETWEEN Q1Start AND Q1Finish
         AND a.ACTION_SCORE = 'Y'
         AND f.INPUT_TYPE = a.ACTION_NAME
         GROUP BY f.COMPANY_NAME)
    GROUP BY a.COMPANY_NAME;
    EXECUTE
    Cheers
    Simon

    Dave had given you already some good advice.
    Your code is not only too complicated, but you have also probably a bug in it. You have for instance a QNstart as to_date('01.01, 'dd.mm') and a corresponding QNfinish as to_date('31.03', 'dd.mm'). As this means, it is the time portion at 00:01, you are missing the complete last day of this interval. So you better do:
    declare
      l_QNstart      date;
      l_Q1start      date;
      l_Q1finish     date;
      l_q1t          number
    begin
      l_QNstart := trunc(sysdate, 'Q');
      l_Q1start := add_months(l_QNstart, -3);
      l_Q1finish := l_QNstart;
      -- your condition is now
      select count(count(*))
      into   l_q1t
      from   ff_actions f, ff_action_type_lov a
      where  f.date_entered >= l_Q1start and f.date_entered < l_Q1finish
      and    a.action_score = 'y'
      and    f.input_type = a.action_name
      group by f.company_name;
    end;
    /Message was edited by:
    Leo Mannhart
    btw: what is the difference between Q1Start / Q3 Start and Q1Finish / Q3Finish resp.?

  • Database.LoadDataSet() method throwing error while retriving data from IBM DB2 database

    Database.LoadDataSet() method is throwing error during retriving data from empty table of IBM DB2 database. It is giving error code "SQL0100W".
    “Error Message: 0NO_DATA [02000] [IBM] [DB2 / NT] SQL0100W FETCH, whether there is a line to be UPDATE or DELETE, or of the query result is an empty table .
    SQLSTATE = 02000”

    Hello SharayuPandit,
    For issues regarding DB2, i suggest that you could post it to DB2 related forum:
    https://www.ibm.com/developerworks/community/forums/html/forum?id=11111111-0000-0000-0000-000000000842
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Processing a data mining structure throws an error

    Processing a data mining structure throws an exception stating the following:
    "Errors in the OLAP storage engine: An error occurred while the 'IDK' attribute of the 'Test  IDK' dimension from the 'Project1' database was being processed."
    "Errors in the OLAP storage engine: The attribute key was converted to an unknown member because the attribute key was not found. Attribute IDK of Dimension: Test IDK from Database: project1, Record:17072643"
    I am using a DB view as a DSV. It does not have a unique primary key. Since DB view is getting multiple results per IDK, the IDK repeats for multiple rows. The same IDK is defined as Key column for the mining model. Not sure if that is the
    issue. Please help!
    Thanks
    Shallu

    Hi Shallu,
    According to your description, you use a database view in the data source view that do not have a primary key, so you get the error
    Errors in the OLAP storage engine: The attribute key was converted to an unknown member because the attribute key was not found. Attribute IDK of Dimension: Test IDK from Database: project1, Record:1707264
    when processing the project, right?
    In this case, please refer to the links below which describe the similar issue.
    http://agilebi.com/ddarden/2009/01/06/analysis-services-error-the-attribute-key-cannot-be-found-when-processing-a-dimension/
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/432deebe-52b8-4245-af85-5aa2eecd421a/scsm2012-cube-processing-failing-on-two-cubes-configitemdimkey-not-found?forum=dwreportingdashboards
    Regards,
    Charlie Liao
    TechNet Community Support

  • Handling invalid Dates In query for Invalid dates in date column.

    Hi,
    I have a date column in my table. This column has corrupted data so the when i use any
    to_timestamp function or any other date calcualtions my query breaks with the error:
    ORA-01843: not a valid month.
    I am aware the data is the issue.
    But i want to handle this scenario by putting nulls in the output when ever an invalid date is encountered.
    I have done some research and found the custom function is_date() on net.
    But i am not suppose to create any new function but handle it with in my query.
    Help is appreciated to handle this scenario.

    Prasath wrote:
    Try this!!
    With Tab As(Select '12/01/2009' txt From dual)
    SELECT Decode(Length(Replace(Translate( txt
    , '0123456789/'
    , Null
    , to_date(txt,'mm/dd/yyyy')
    , NULL) As Validation_date
    FROM tab;
    Ok ...
    SQL> With Tab As(Select '12/01/2009' txt From dual)
      2      SELECT Decode(Length(Replace(Translate( txt
      3                                            , '0123456789/'
      4                                            , '#')
      5                                  ,'#'))
      6                   , Null
      7                   , to_date(txt,'mm/dd/yyyy')
      8                   , NULL) As Validation_date
      9       FROM tab;
    VALIDATIO
    01-DEC-09Not sure what that proves, especially in relation to the OP's problem.

  • Why HTTPService is throwing error when there is two or less rows of data ?!

    Hi guys,
    I have an issue with HTTPService which is this.
    I'm using HTTPService to retrieve data from SQL database, and to display those data in datagrid.
    Basically MXML and script is like this :
    example code  ---------------------------------------------------------------------
    <mx:HTTPService id="readRequestC"
                                       method="POST"
                                       useProxy="false"
                                       url="http://www.mydomain.com/read_record.php"
                                       result="showActiveAlerts(event)">
    </mx:HTTPService>
    private function showActiveAlerts(e:ResultEvent):void
                                       C_activealerts_AC = e.result.patientalert.alert                         
    end of code ------------------------------------------------------------------------
    C_activealerts_AC - array collection is bound to data grid
    I'm using this read_record.php file to retrieve data from database :
    example code  ---------------------------------------------------------------------
    <?php
    define( "DATABASE_SERVER", "xxx" );
    define( "DATABASE_USERNAME", "xxx" );
    define( "DATABASE_PASSWORD", "xxx" );
    define( "DATABASE_NAME", "xxx" );
    //connect to the database.
    $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
    mysql_select_db( DATABASE_NAME );
    $Query = "SELECT * FROM patientalert";
    $Result = mysql_query( $Query );
    // ----------------------------------- xml is constructed here -------------------
    $Return = "<patientalert>";
                while ( $User = mysql_fetch_object( $Result ) )  
                $Return .= "<alert>
                                                   <idstaff>".$User->idstaff."</idstaff>
                                                   <idpatient>".$User->idpatient."</idpatient>
                                                   <idalerttype>".$User->idalerttype."</idalerttype>
                                                   <idalertstatus>".$User->idalertstatus."</idalertstatus>
                                                    <timestampappear>".$User->timestampappear."</timestampappear>
                                                   <timestampproceed>".$User->timestampproceed."</timestampproceed>
                                                   <position>".$User->position."</position>
                                                   <mobileid>".$User->mobileid."</mobileid>
                                                   </alert>";
    $Return .= "</patientalert>";
    mysql_free_result( $Result );
    print ($Return)
    ?>
    end of code ------------------------------------------------------------------------
    This php file above is creating nice XML file which I'm reading with HTTPService. Everything is working fine when there is a lot of data (at least several rows)
    The point is, that data is changing constantly in SQL base, there can be 10 rows, but there can be 3 of them... and here is the problem.
    When there is less than 2 row of data... an error appears :
    TypeError: Error #1034: Can not convert type mx.utils::ObjectProxy@4011089 to type mx.collections.ArrayCollection....
    I'm sure this problem is due to fact that when there is only one row in database we don't have several <alert> nodes in XML so it cannot be converted into ArrayCollection.
    Do you have any idea how to prevent this ? How to convert one row of data from database to valid Array Collection... and what if there will be no data in the table... in that case I simply want to display no data in data grid !
    Thanks for any help !!!

    >>>> Im imagine you're feeding the HTTPService lastResult into an array collection, and then binding that to the Datagrid.
    yes indeed... I'm doing precisely that :
    I've got an array collection
                [Bindable]
                private var C_activealerts_AC:ArrayCollection=new ArrayCollection()
    which is bound to datagrid :
    <mx:DataGrid dataProvider="{C_activealerts_AC}">
                 <mx:columns>
                        <mx:DataGridColumn headerText="Staff" dataField="idstaff"/>
                        <mx:DataGridColumn headerText="Patient" dataField="idpatient"/>
                        <mx:DataGridColumn headerText="Type" dataField="idalerttype"/>
                        <mx:DataGridColumn headerText="Status" dataField="idalertstatus"/> ...etc..
                 </mx:columns>
    </mx:DataGrid>
    and I'm pushing event.result to C_activealerts_AC, like this :
    <mx:HTTPService id="readRequestC"
                        method="POST"
                        useProxy="false"                   
                        url="http://www.mydomain.com/read_record.php"
                        result="showActiveAlerts(event)">       
    </mx:HTTPService>
    private function showActiveAlerts(e:ResultEvent):void {
         C_activealerts_AC = e.result.patientalert.alert
    Now... I'm looking at your solution but I'm not quite catching it ... you have
    two results in HTTPService ? Compiler doesn't like this it's shouting 'result has been defined once' !
    result="handleRequestC(event)"
    result="showActiveAlerts(event)"
    and what is this 'Datagrid' below... is it an id of my datagrid ?? hmm..
    Datagrid.dataprovider = evt.result.patientalert.alert;
    Could you please explain it a little more ?
    I thought if there is one row of data, array collection will be feeded only with one object... apparently, like you say, it's not
    Thanx

  • Web Analysis Error -- Error while executing query and retrieving data

    Regarding Web Analysis:
    We have a number of reports that we created. yesterday they were all working fine. today we try to open them and most are generating an error.
    The error is:
    Error while executing query and retrieving data.; nested exception is:
    com.hyperion.ap.APException: [1033] Native:
    1013033[Thu Oct 22 09:08:17
    2009]server name/application name/database name/user name/Error91013033)
    ReportWriter exit abnormally
    Does anyone have any insight into what is going on?
    My version information is:
    Hyperion System 9 BI+ Analytic Administration Services 9.3.0.1.1 Build 2
    Web Analysis 9.3.0.0.0.286
    Thanks in advance for your help.
    DaveW

    Hi,
    And also click on check option by opening the query in Query designer,as Mr . Arun suggested.
    And if you get any error in checking, see the long message(detail).
    With rgds,
    Anil Kumar Sharma .P

  • No Data Shown because an error occurred while running the query

    Discoverer 10gR2 using Plus on Firefox:
    I have one workbook. The first sheet summarizes by Vendor. Parameters are Type, Category, Vendor (all optional) and mandatory date range.
    The second sheet summarized by Vendor and Model. Parameters are Type, Category, Vendor, Model (all optional) and mandatory date range.
    All parameters except the extra "Model" are shared between the sheets.
    When I run the Vendor sheet, parameters pop up, I put in dates and leave the rest blank. Results display. Yeah!
    When I then run the Model sheet, parameters pop up again (because it has one more parameter). Dates carry forward, leave the rest blank. I get the error No Data Shown because an error occurred while running the query. Refreshing does not help.
    If I click back to the Vendor sheet, then come back to the Model sheet, no parameter screen and the query runs.
    Booooo.
    Have tried multiple DBs, multiple EULs, multiple underlying data sources, replacing the offending parameter with a whole new one, no difference.
    Has any body run into this behavior? Is there an answer?
    -- Ron Olcott, Business Intelligence Product Manager

    What about trying this. On the parameter definition, you have a section on the bottom left of the Parameters window, called "Do you want to allow different parameter values for each worksheet?". When you say in your posting that all but the Model parameter is shared, I assume you mean that you have set this section value to "Allow only one set of paratmeter values for all worksheets". Try setting this to "Allow different parameter values for each worksheet". See if that might make a difference for you. If that works, you may have to leave the option at this, as the lesser of your evils. From my limited experience, the "Allow only one set of parameter mvalues for all worksheets" is a bit flaky in how it works. So I pretty much have gone to always saying to allow different parameter values for each worksheet. Hope this helps a bit. If worse comes to worse, if you have not done so already, log a service request with support and see what they say. Good luck.
    John DIckey

  • Error giving a default value to a date column in the attribute settings.

    When im giving a default value to a date column in the attribute settings i get this error when im running my jsp page (bc4j web application):
    Error Message: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value: 31-dic-2099
    How can i fix that?
    Thank u

    The default date format for oracle.sql.DATE which oracle.jbo.domain.Date extends is "YYYY-MM-DD"

Maybe you are looking for

  • Choosing a PXIe controller for streaming 200 MBps

    Warning:  This is a long post with several questions.  My appologies in advance. I am a physics professor at a small liberal-arts college, and will be replacing a very old multi-channel analyzer for doing basic gamma-ray spectroscopy.  I would like t

  • Macbook Pro 13" (Late 2013) does not connect to Wifi

    Hi, I just bought a new macbook pro 3 days back. It was working fine till it suddenly dropped connection to the home WiFi. Since then it shows a list of wifi options including the one that i was connected to but does not connect to it. The error mess

  • Conversion of Purchase Order sap withgoods reciept done

    Hi In legacy system the Purchase order and goods receipt done ,now the invoice is to be done in  SAP. Can you please advice how the invoice can be posted in SAP,with reference to purchase order or create an invoice in FI. Please advice. Regards Rekha

  • Albums in iCloud photo library

    Can I create albums in iCloud Photo Library that are visib across all my devices? ALso, can I add photo albums from my PC(not taken on iOS device) to my library?

  • Is it possible to change the app icon for websites?

    Hi, I have created a web shortcut to my home screen, at the moment the icon defaults to a shot of the web page (although very small) and was wondering if it was possible to change the app icon ?