Question

I am trying to convert string into date using the following code in PL/SQL:

BEGIN
   vfrom := TO_DATE ('20/08/2013', 'dd/mm/yyyy');
   vto := TO_DATE ('30/08/2013', 'dd/mm/yyyy');

   OPEN L_CURSOR FOR
      SELECT DSAT.ORGANIZATION_ID,
             APPS.DAW_INV_ORG_NAME (DSAT.ORGANIZATION_ID) ORGANIZATION_NAME,
             APPS.DAW_CAT_NAME (MC.SEGMENT4) PRODUCT,
             TRUNC (NVL (DSAT.SCH_END_DATE, DSAT.SCH_START_DATE))
                TRANSACTION_DATE,
             TO_CHAR (NVL (DSAT.SCH_END_DATE, DSAT.SCH_START_DATE),
                      'MM-YYYY')
                MONTH,
             DSAT.ITEM_SEGMENTS ITEM_CODE,
             DSAT.ITEM_DESCRIPTION,
             DSAT.CURRENT_FORECAST_QUANTITY PLAN_QTY
        FROM APPS.DAW_SCPDB_ASCP_TPP_V DSAT,
             APPS.MTL_ITEM_CATEGORIES MIC,
             APPS.MTL_CATEGORIES MC
       WHERE     NVL (SCH_END_DATE, SCH_START_DATE) BETWEEN '$(vfrom)'
                                                        AND '$(vto)'
             AND MIC.CATEGORY_SET_ID = 1100000061         --- PLANING CATEGORY
             AND MC.CATEGORY_ID = MIC.CATEGORY_ID
             AND DSAT.INVENTORY_ITEM_ID = MIC.INVENTORY_ITEM_ID
             AND DSAT.ORGANIZATION_ID = MIC.ORGANIZATION_ID
             AND DSAT.FORECAST_SET = '$(vForecastSetDPL2)'; --- Need to Update it on Monthly Basis;
END PorductPlanningForecast;

Error occurs as

ORA-01858: a non-numeric character was found where a numeric was expected on line 29

which consists of opening cursor for query. I have checked NSL parameters and set date to the format here in to_Date function, searched all over the internet and yet i cant figure it out. Please help.

Was it helpful?

Solution

In line WHERE NVL(SCH_END_DATE,SCH_START_DATE) BETWEEN '$(vfrom)' and '$(vto)' you have implicit conversion of string '$(vfrom)' to date. That's not going to work.

Assuming that vfrom and vto are declared as date, the line should be like this WHERE NVL(SCH_END_DATE,SCH_START_DATE) BETWEEN vfrom and vto.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top