ORA-01841 - (full) year must be between -4713 and +9999, and not be 0

Hi Comunnity,
Let me explain the scenario:
We want to replicate a number of Discoverer reports, adding more columns to the reports. Due to the internal structure of the views and materialized tables, we can not make the joins inside the Discoverer Administration Edition, so we have decided to replicate the original materialized table adding the columns in order to get what we want. So the new materialized table has built as follows:
CREATE TABLE APPS.GUZMAN_STOCK_DEPRE_EXIST_MAT_X
EMPRESA VARCHAR2(240 BYTE),
COD_ORGANIZACION NUMBER,
COD_SECCION VARCHAR2(40 BYTE),
SECCION VARCHAR2(4000 BYTE),
FAMILIA VARCHAR2(40 BYTE),
NOMBRE_PRODUCTO VARCHAR2(240 BYTE),
DESCRIPCION_ARTICULO VARCHAR2(240 BYTE),
UNIDAD_EXISTENCIA_ACT NUMBER,
PRECIO_MEDIO NUMBER,
FECHA_ULT_VENTA DATE,
FECHA_ULT_COMPRA DATE,
FECHA_ULT_MOVIMIENTO DATE,
PRECIO_ULT_COMPRA NUMBER,
CLASE_UNIDAD VARCHAR2(40 BYTE),
COD_ORG_INV NUMBER,
ORG_INV_NAME VARCHAR2(240 BYTE),
COD_ARTICULO NUMBER,
AÑO VARCHAR2(2 BYTE),
MES VARCHAR2(2 BYTE),
ULTIMO_DIA_TRANS DATE,
SEIS_MESES_ANTES DATE,
DOCE_MESES_ANTES DATE,
DIECIOCHO_MESES_ANTES DATE,
SEIS_MESES NUMBER,
SIETE_DOCE_MESES NUMBER,
TRECE_DIECIOCHO_MESES NUMBER,
FCOMVACIA NUMBER,
TIPO_ARTICULO VARCHAR2(80 BYTE),
TRANSACTION_ID NUMBER,
FECHA_MOVIMIENTO DATE,
TIPO_MOVIMIENTO VARCHAR2(80 BYTE)
TABLESPACE APPLSYSD
PCTUSED 40
NOMONITORING;
The bold fields are the new ones. So we added the materialized table as a new folder in our working business area and add the following new intems:
Valor Compra = CASE WHEN Precio Ult Compra = 0 THEN Importe Stocks ELSE Unidad Existencia Act*Precio Ult Compra END
Importe Stocks = Unidad Existencia Act*Precio Medio
Depreciación = CASE WHEN Valor Compra < Importe Stocks THEN Importe Stocks-Valor Compra ELSE 0 END
DiasMes = CASE WHEN ((((((Mes = '01' OR Mes = '03') OR Mes = '05') OR Mes = '07') OR Mes = '08') OR Mes = '10') OR Mes = '12') THEN 31 WHEN (((Mes = '04' OR Mes = '06') OR Mes = '09') OR Mes = '11') THEN 30 ELSE 28 END
fecha_MES = TO_NUMBER(CONCAT(DiasMes,Mes))
Nueva_Fecha = TO_DATE(CONCAT(fecha_MES,Ano))
Dias = NVL(Nueva_Fecha-Fecha Ult Venta,0)
PorcenDepre = CASE WHEN Dias = 0 AND DiasC < 181 THEN 0 WHEN Dias = 0 AND DiasC > 180 THEN 100 WHEN Dias < 181 THEN 0 WHEN Dias < 361 THEN 25 WHEN Dias < 540 THEN 50 WHEN Dias > 541 THEN 100 ELSE 0 END
Valor Depr = Valor Compra*PorcenDepre/100
DiasC = NVL(Nueva_Fecha-Fecha Ult Compra,0)
PorcenDepreC = CASE WHEN DiasC = 0 THEN 100 WHEN DiasC < 181 THEN 0 WHEN DiasC < 361 THEN 25 WHEN DiasC < 540 THEN 50 WHEN DiasC > 541 THEN 100 ELSE 0 END
Valor DepreC = Valor Compra*PorcenDepreC/100
T6 = CASE WHEN Unidad Existencia Act >= SEISMESES THEN SEISMESES ELSE Unidad Existencia Act END
T12 = CASE WHEN Unidad Existencia Act-T6 > DOCEMESES THEN DOCEMESES WHEN Unidad Existencia Act-T6 < DOCEMESES THEN Unidad Existencia Act-T6 WHEN Unidad Existencia Act-T6 = DOCEMESES THEN Unidad Existencia Act-T6 END
T18 = CASE WHEN Unidad Existencia Act-( T6+T12 ) > DIECIOCHOMESES THEN DIECIOCHOMESES WHEN Unidad Existencia Act-( T6+T12 ) < DIECIOCHOMESES THEN Unidad Existencia Act-( T6+T12 ) WHEN Unidad Existencia Act-( T6+T12 ) = DIECIOCHOMESES THEN Unidad Existencia Act-( T6+T12 ) END
TR = Unidad Existencia Act-( T6+T12+T18 )
DT6 = T6*Precio Medio*0/100
DT12 = ( T12*Precio Medio )*25/100
DT18 = T18*Precio Medio*50/100
DTR = TR*Precio Medio*100/100
DTOTAL = DT6+DT12+DT18+DTRVCIA+DFCOMPVCIA
SEISMESES = CASE WHEN NVL(Seis Meses,0) < 0 THEN 0 ELSE NVL(Seis Meses,0) END
DOCEMESES = CASE WHEN NVL(Siete Doce Meses,0) < 0 THEN 0 ELSE NVL(Siete Doce Meses,0) END
DIECIOCHOMESES = CASE WHEN NVL(Trece Dieciocho Meses,0) < 0 THEN 0 ELSE NVL(Trece Dieciocho Meses,0) END
FCOMPVCIA = DECODE(Fecha Ult Compra,NULL,Unidad Existencia Act,0)
TRVCIA = TR-FCOMPVCIA
DTRVCIA = TRVCIA*Precio Medio*100/100
DFCOMPVCIA = FCOMPVCIA*Precio Medio*100/100
Due to Discoverer does not allow foreign characters (ñ), we have changed the name of Field Año to Ano (as you can check in the Nueva_Fecha calculated field).
Now, when we select the fields (Empresa, Cod Sección, Nombre Producto, Unidad Existencia Act, Precio Medio, Fecha Ult Venta, Fecha Ult Compra, Fecha Ult Movimiento, Precio Ult Compra, Org Inv Name, Ano, Mes, Valor Compra, Importe Stocks, Depreciación, Dias, PorcenDepre, Valor Depr, DiasC, PorcenDepreC, ValorDepreC) in order to build a new report, Discoverer shows us the ORA-01841 Error.
Can be produced the error by the way in which discoverer stores the Nueva_Fecha Field?, cause as we check the field in Adminostration Edition, it appears as TO_DATE(CONCAT(fecha_MES,'Ano')) (with the field Ano in simple quotes), or just by any other circumstance?
Thanks a lot for your help.
Luis.
Update:*
It seems that the problem comes with the item created in Discoverer Administration Edition "Nueva_Fecha":
Nueva_Fecha = TO_DATE(CONCAT(fecha_MES,Ano))
(Keep in mind that:
fecha_MES = TO_NUMBER(CONCAT(DiasMes,Mes))
DiasMes = CASE WHEN ((((((Mes = '01' OR Mes = '03') OR Mes = '05') OR Mes = '07') OR Mes = '08') OR Mes = '10') OR Mes = '12') THEN 31 WHEN (((Mes = '04' OR Mes = '06') OR Mes = '09') OR Mes = '11') THEN 30 ELSE 28 END
), so any created field that uses Nueva_Fecha or is derivated from Nueva_Fecha causes the error (e.g. --> Dias = NVL(Nueva_Fecha-Fecha Ult Venta,0))
Then; How can we configure the field in order that discoverer deals with it as a date field?
Regards,
Luis.
Edited by: GGOracle User on 27-may-2010 15:23

Hi,
I think you forgot the separator in the string you want to convert to date.
Your problem lies in the format of the date you are trying to create.
try
Nueva_Fecha = TO_DATE(DiasMes||'-'||Mes||'-'||Ano ,'DD-MM-YYYY')
BTW
you can use || instead of CONCAT so that you can concatenate more than 2 values each time
Tamir

Similar Messages

  • Regarding the error ORA-01841: (full) year must be between -4713 and +9999,

    The issue is the code is not inserting the good records into the MIE table. This is becasue of the error 'OtherError GFSTM_INS_SNURK_NEW_TABLES_PA.gfstm_ins_asn_journal_pr:ORA-01841: (full) year must be between -4713 and +9999, and not be 0' This error is throwing out because of space issue in dt_asn_shipped.
    My requirement is to log error if any if not get the next record in the loop and insert it in the table if it has no error. The issue is good records are not getting inserted. The snurk_cmms_crct018_asn_journl in the cursor is a synonym which uses dblionk to connect to the remote db. The dt_asn_shipped data type is char(6) and the format is YYMMDD.
    declare
    CURSOR cur_asn_journal IS
    SELECT NVL(TRIM(cd_asn_plant),' ') cd_asn_plant,
         NVL(TRIM(no_journal),0) no_journal,
    NVL(TRIM(cd_ship_from),' ') cd_ship_from,
         TRIM(no_asn) no_asn,
    DECODE(LENGTH(dt_asn_shipped),6, to_date(to_char(to_date(trim(dt_asn_shipped),'YYMMDD'),
    'DD-MON-YY'),'DD-MON-YY'), '') dt_asn_shipped,
    TRIM(dt_processed) dt_processed,
    TRIM(in_manual) in_manual,
         TRIM(ts_last_update) ts_last_update     
    FROM snurk_cmms_crct018_asn_journl;
    BEGIN
    FOR l_rec_asn_journal IN cur_asn_journal LOOP
    BEGIN
    INSERT INTO gfstmie_st_cmms_asn_journal
    gsdb_site_code ,
    journal_num,
    gsdb_site_from_code,
    adv_shipping_notice_cnum,
    adv_sn_shipping_date,
    processed_date,
    manual_in_code,
    cmms_last_update_cdate,
    create_userid,
    create_dts,
    update_userid,
    update_dts
    ) VALUES
    l_rec_asn_journal.cd_asn_plant,
    l_rec_asn_journal.no_journal,
    l_rec_asn_journal.cd_ship_from,
    l_rec_asn_journal.no_asn,
    l_rec_asn_journal.dt_asn_shipped,
    l_rec_asn_journal.dt_processed,
    l_rec_asn_journal.in_manual,
    l_rec_asn_journal.ts_last_update,
    g_con_user_id,
         l_dts_current_gmt,
    g_con_user_id,
    l_dts_current_gmt
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('l_num_exception_pt_7');
    --To assign value to error attributes
    l_str_email_body := GFSTU_MSG_CONTEXT_STACKER_PA.gfstu_add_msg_context_fn(
    SQLERRM || l_str_process_track,
    g_con_package_name || l_con_proc_name,
    g_con_string_null);
    l_rec_apm_error_attributes.job_run_sakey := l_num_job_run_id;
    l_rec_apm_error_attributes.proj_acronym_code := GFSTM_PARM_SPECIFICATION_PA.g_con_proj_acronym_code_ta;           
    l_rec_apm_error_attributes.module_code := l_con_module_code;
    l_rec_apm_error_attributes.notes_text := l_str_email_body;
    l_rec_apm_error_attributes.msg_id := GFSTM_PARM_SPECIFICATION_PA.g_con_msg_id_invalid_date;
    --Calling procedure to log and notify subscribers of transaction
    --related errors and informational messages
    GFSTM_COMMON_UTL_PA.gfstm_log_message_pr(
    SUBSTR(l_str_email_body,1,2000),
    g_con_string_null,
    g_con_string_null,
    SUBSTR(l_str_email_body,1,2000),
    l_rec_apm_error_attributes,
    g_con_string_null,
    l_num_wait_time,
    l_num_wait_interval_time,
    l_str_msg_action_code,
    l_num_oracle_error_code,
    l_str_oracle_msg,
    l_num_return_code,
    l_num_status);
    END;
    END LOOP;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('l_num_exception_pt_12');
    DBMS_OUTPUT.PUT_LINE('l_num_exception_pt_2 '||l_str_procg_mode_code);
    --Rollback uncommitted transactions
    ROLLBACK;
    --Assigning failure status
    o_num_status := g_con_status_failure;
    --Assigning procedure end time in GMT
    l_dts_end_time := GFSTU_DATETIME_UTILITIES_PA.gfstu_to_gmt_fn;
    --To assign value to error attributes
    l_str_email_body := GFSTU_MSG_CONTEXT_STACKER_PA.gfstu_add_msg_context_fn(
    SQLERRM || l_str_process_track,
    g_con_package_name || l_con_proc_name,
    g_con_string_null);
    l_rec_apm_error_attributes.job_run_sakey := l_num_job_run_id;
    l_rec_apm_error_attributes.proj_acronym_code := GFSTM_PARM_SPECIFICATION_PA.g_con_proj_acronym_code_ta;           
    l_rec_apm_error_attributes.module_code := l_con_module_code;
    l_rec_apm_error_attributes.notes_text := l_str_email_body;
    l_rec_apm_error_attributes.msg_id := GFSTM_PARM_SPECIFICATION_PA.g_con_msg_id_oracle;
    --Calling procedure to log and notify subscribers of transaction
    --related errors and informational messages
    GFSTM_COMMON_UTL_PA.gfstm_log_message_pr(
    SUBSTR(l_str_email_body,1,2000),
    g_con_string_null,
    g_con_string_null,
    SUBSTR(l_str_email_body,1,2000),
    l_rec_apm_error_attributes,
    g_con_string_null,
    l_num_wait_time,
    l_num_wait_interval_time,
    l_str_msg_action_code,
    l_num_oracle_error_code,
    l_str_oracle_msg,
    l_num_return_code,
    l_num_status);
    --Calling procedure to update the job status
    GFSTM_COMMON_UTL_PA.gfstm_update_job_status_pr(
    l_num_job_run_id,
    GFSTM_PARM_SPECIFICATION_PA.g_con_process_abort,
    l_dts_end_time,
    g_con_perf_metric_code,
    g_con_zero,
    g_con_n,
    l_num_oracle_error_code,
    l_str_oracle_msg,
    l_num_return_code,
    l_num_status);
    END ;
    Thanks,
    Vinodh

    Hi,
    Could you not have reduced your question to what is relevant?
    You seem to be saying that this is your problem:
    SELECT DECODE ( LENGTH (dt_asn_shipped),
              6,
              TO_DATE ( TO_CHAR ( TO_DATE ( TRIM (dt_asn_shipped), 'YYMMDD'), 'DD-MON-YY'), 'DD-MON-YY'),
             dt_asn_shipped
    FROM   snurk_cmms_crct018_asn_journl;As far as I can see, problem might be that you decode on UNTRIMMED length.
    Also, you could get rid of some the to_date(to_char(to_date), which is nothing more than simply to_date()
    Try something like
    SELECT CASE LENGTH (TRIM (dt_asn_shipped))
             WHEN 6 THEN TO_DATE ( TRIM (dt_asn_shipped), 'YYMMDD')
           END
             dt_asn_shipped
    FROM   snurk_cmms_crct018_asn_journl;Regards
    Peter

  • Error ORA-01841: (full) year must be between -4713 and +9999, and not be 0

    Hi Experts,
    I seem to be getting the error "Error ORA-01841: (full) year must be between -4713 and +9999, and not be 0" when my dates are in the year 2000. Here's my SQL:
    DROP TABLE PER_ALL_ASSIGNMENTS_M_XTERN;
    create table PER_ALL_ASSIGNMENTS_M_XTERN(
    PERSON_NUMBER                    VARCHAR2(30 CHAR),
    ASSIGNMENT_NUMBER VARCHAR2(30 CHAR),
    EFFECTIVE_START_DATE                DATE,
    EFFECTIVE_END_DATE           DATE,
    EFFECTIVE_SEQUENCE           NUMBER(4),
    ASS_ATTRIBUTE_CATEGORY           VARCHAR2(30 CHAR),
    ASS_ATTRIBUTE1 VARCHAR2(150 CHAR),
    ASS_ATTRIBUTE_NUMBER20 NUMBER,
    ASS_ATTRIBUTE_DATE1 DATE,
    ASS_ATTRIBUTE_DATE2 DATE,
    ASS_ATTRIBUTE_DATE3 DATE,
    ASS_ATTRIBUTE_DATE4 DATE,
    ASS_ATTRIBUTE_DATE5 DATE,
    ASS_ATTRIBUTE_DATE6 DATE,
    ASS_ATTRIBUTE_DATE7 DATE,
    ASS_ATTRIBUTE_DATE8 DATE,
    ASS_ATTRIBUTE_DATE9 DATE,
    ASS_ATTRIBUTE_DATE10 DATE,
    ASS_ATTRIBUTE_DATE11 DATE,
    ASS_ATTRIBUTE_DATE12 DATE,
    ASS_ATTRIBUTE_DATE13 DATE,
    ASS_ATTRIBUTE_DATE14 DATE,
    ASS_ATTRIBUTE_DATE15 DATE,
    ASG_INFORMATION_CATEGORY           VARCHAR2(30 CHAR),
    ASG_INFORMATION1 VARCHAR2(150 CHAR),
    ASG_INFORMATION_NUMBER20 NUMBER,
    ASG_INFORMATION_DATE1 DATE,
    ASG_INFORMATION_DATE2 DATE,
    ASG_INFORMATION_DATE3 DATE,
    ASG_INFORMATION_DATE4 DATE,
    ASG_INFORMATION_DATE5 DATE,
    ASG_INFORMATION_DATE6 DATE,
    ASG_INFORMATION_DATE7 DATE,
    ASG_INFORMATION_DATE8 DATE,
    ASG_INFORMATION_DATE9 DATE,
    ASG_INFORMATION_DATE10 DATE,
    ASG_INFORMATION_DATE11 DATE,
    ASG_INFORMATION_DATE12 DATE,
    ASG_INFORMATION_DATE13 DATE,
    ASG_INFORMATION_DATE14 DATE,
    ASG_INFORMATION_DATE15 DATE
    organization external
    ( default directory APPLCP_FILE_DIR
    access parameters
    ( records delimited by newline skip 1
         badfile APPLCP_FILE_DIR:'PER_ALL_ASSIGNMENTS_M_XTERN.bad'
    logfile APPLCP_FILE_DIR:'PER_ALL_ASSIGNMENTS_M_XTERN.log'
    fields terminated by ',' OPTIONALLY ENCLOSED BY '"'
    (PERSON_NUMBER,     
    ASSIGNMENT_NUMBER,
    EFFECTIVE_START_DATE CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    EFFECTIVE_END_DATE CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    EFFECTIVE_SEQUENCE,
    ASS_ATTRIBUTE_CATEGORY,
    ASS_ATTRIBUTE1,
    ASS_ATTRIBUTE_NUMBER20,
    ASS_ATTRIBUTE_DATE1 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE2 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE3 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE4 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE5 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE6 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE7 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE8 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE9 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE10 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE11 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE12 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE13 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE14 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASS_ATTRIBUTE_DATE15 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_CATEGORY,
    ASG_INFORMATION1,
    ASG_INFORMATION_NUMBER20,
    ASG_INFORMATION_DATE1 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE2 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE3 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE4 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE5 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE6 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE7 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE8 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE9 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE10 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE11 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE12 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE13 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE14 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY",
    ASG_INFORMATION_DATE15 CHAR(20) DATE_FORMAT DATE MASK "DD-MON-YYYY"
    location ('PER_ALL_ASSIGNMENTS_M.csv')
    REJECT LIMIT UNLIMITED;
    ...and getting errors when data looks like the following:
    E040101,EE040101,*1-Aug-2000*,31-Dec-4712,1,,NDVC,YES,DE,SFC,N,STIP Plan - Pressure,,,,,,,E040101,,,,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,,,,,,,,,,,,31113,31113,31113,31113,31113,31113,,,1-Jan-2012,31-Dec-2012,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    ...error message:
    error processing column EFFECTIVE_START_DATE in row 19 for datafile /u05/dbadir/jmf/incident_logs/PER_ALL_ASSIGNMENTS_M.csv
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    Thanks,
    Thai

    Here is a snippet of the bad file data:
    E040110,EE040110,01-Aug-00,31-Dec-12,1,,NDVC,YES,DE,SFC,N,STIP Plan - Pressure,,,,,,,E040110,,,,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,,,,,,,,,,,,27667.2,27667.2,27667.2,27667.2,27667.2,27667.2,,,01-Jan-12,31-Dec-12,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    E040100,EE040100,01-May-00,31-Dec-12,1,,NDVC,YES,DE,SFC,N,STIP Plan - Pressure,,,,,,,E040100,,,,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,,,,,,,,,,,,31113,31113,31113,31113,31113,31113,,,01-Jan-12,31-Dec-12,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    E040101,EE040101,01-Aug-00,31-Dec-12,1,,NDVC,YES,DE,SFC,N,STIP Plan - Pressure,,,,,,,E040101,,,,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,,,,,,,,,,,,31113,31113,31113,31113,31113,31113,,,01-Jan-12,31-Dec-12,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    E000916,EE000916,01-Oct-00,31-Dec-12,1,,NDVC,YES,NL,SFC-Commercial,E,SIP Plan - Control Technologies,,,,,,,E000916,21000000,555000,99000,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,10,,,,,,,,,,,,34905.65,34905.65,34905.65,34905.65,34905.65,34905.65,,,01-Jan-12,31-Dec-12,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    E000807,EE000807,03-Jan-00,31-Dec-12,1,,NDVC,YES,FR,SFC-Commercial,E,STIP Plan - Cross BU,,,,,,,E000807,,,,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,,,,,,,,,,,,35448.56,35448.56,35448.56,35448.56,35448.56,35448.56,,,01-Jan-12,31-Dec-12,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    E000851,EE000851,25-Apr-00,31-Dec-12,1,,NDVC,YES,FR,SFC-Commercial,E,SIP Plan - Control Technologies,,,,,,,E000851,21000000,555000,99000,2080,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,13,,,,,,,,,,,,43283.76,43283.76,43283.76,43283.76,43283.76,43283.76,,,01-Jan-12,31-Dec-12,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    So, the successfully loaded data is being loaded where year=2003 in the CSV as year=0003. Even though the data is loaded fine the data is not correct. For some reason the external table is set to have the year truncated.

  • ORA-01841 full year must be between .....error when order by

    Hi all
    i have this query with me ,when order by clause is included ,when it is removed ,i see the output with  so  many record counts
    SELECT   porh.segment1,
             CASE
                WHEN popr.action_code = 'APPROVE'
                AND prall.full_name <> 'Sudheer T. Paraputhra'
                AND grdpr.short_name < 'PS-10'
                   THEN prall.full_name
             END directman_pr,-----getting names of managers who perform PR approve action
             porh.description, porl.line_num,
             CASE
                WHEN popr.action_code = 'APPROVE'
                AND prall.full_name <> 'Sudheer T. Paraputhra'
                AND grdpr.short_name < 'PS-10'
                AND poph.action_code = 'SUBMIT'
                   THEN TO_NUMBER (  TO_CHAR (  TO_DATE ('1', 'J')
                                              + (  poph.action_date
                                                 - popr.action_date
                                              'J'
                                   - 1
             END days_pr,------------------------------(calculating days from PR approval by manager to PO submit by user)
             poha.segment1 po_num, prall.full_name pr_approved_by,
             popr.action_date pr_approved_date,
             CASE
                WHEN poall_apprv.full_name <> 'Sudheer T. Paraputhra'
                AND grdpo_apprv.short_name < 'PS-10'
                AND poph_apprv.action_code = 'APPROVE'
                AND poph.action_code = 'SUBMIT'
                   THEN TO_NUMBER (  TO_CHAR (  TO_DATE ('1', 'J')
                                              + (  poph_apprv.action_date
                                                 - poph.action_date
                                              'J'
                                   - 1
             END days_po,------calculating days  from PO submit action by user to PO approve action by managers
             popr.sequence_num pr_seq, popr.action_code pr_action,
             poall.full_name po_approved_by, poph.action_date po_approved_date,
             poph.sequence_num po_seq, poph.action_code po_action,
             poph_apprv.action_date po_approved_date_appr,
             poph_apprv.action_code apprv_action_code
        FROM po_requisition_headers_all porh,
             po_requisition_lines_all porl,
             po_req_distributions_all prda,
             po_distributions_all poda,
             po_headers_all poha,
             po_action_history popr,
             po_action_history poph,
             hr.per_all_people_f poall,
             hr.per_all_people_f prall,
             hr.per_all_assignments_f asgpo,
             hr.per_all_assignments_f asgpr,
             per_grades_vl grdpo,
             per_grades_vl grdpr,
             po_headers_all poha_apprv,
             po_distributions_all poda_apprv,
             po_action_history poph_apprv,
             hr.per_all_people_f poall_apprv,
             hr.per_all_assignments_f asgpo_apprv,
             per_grades_vl grdpo_apprv
       WHERE poph.employee_id = poall.person_id
         AND popr.employee_id = prall.person_id
         AND poall.person_id = asgpo.person_id
         AND prall.person_id = asgpr.person_id
         AND asgpr.grade_id = grdpr.grade_id(+)
         AND asgpo.grade_id = grdpo.grade_id(+)
         AND prda.distribution_id = poda.req_distribution_id
         AND poha.po_header_id = poda.po_header_id
         AND prda.requisition_line_id = porl.requisition_line_id
         AND porh.requisition_header_id = porl.requisition_header_id
         AND porh.requisition_header_id = popr.object_id
         AND poph.object_type_code = 'PO'
         AND poha.po_header_id = poph.object_id
         AND SYSDATE BETWEEN poall.effective_start_date AND poall.effective_end_date
         AND SYSDATE BETWEEN prall.effective_start_date AND prall.effective_end_date
         AND SYSDATE BETWEEN asgpo.effective_start_date AND asgpo.effective_end_date
         AND SYSDATE BETWEEN asgpr.effective_start_date AND asgpr.effective_end_date
         AND SYSDATE BETWEEN poall_apprv.effective_start_date
                         AND poall_apprv.effective_end_date
         AND SYSDATE BETWEEN asgpo_apprv.effective_start_date
                         AND asgpo_apprv.effective_end_date
         AND prda.distribution_id = poda_apprv.req_distribution_id
         AND poha_apprv.po_header_id = poda_apprv.po_header_id
         AND poph_apprv.employee_id = poall_apprv.person_id
         AND poall_apprv.person_id = asgpo_apprv.person_id
         AND asgpo_apprv.grade_id = grdpo_apprv.grade_id(+)
         AND poha_apprv.po_header_id = poph_apprv.object_id
         AND poph_apprv.object_type_code = 'PO'
         AND poph_apprv.action_code = 'APPROVE'
    ORDER BY 4, 10, 14the calcuation works fine except for when order by clause is inlcuded
    kindly help
    Edited by: makdutakdu on Jun 1, 2010 2:51 PM

    hi Alex,John
    even i am confused as to why its happening ,
    SELECT   porh.segment1,
             CASE
                WHEN popr.action_code = 'APPROVE'
                AND prall.full_name <> 'Sudheer T. Paraputhra'
                AND grdpr.short_name < 'PS-10'------------< 'PS-10'
                   THEN prall.full_name
             END directman_pr,
             porh.description, porl.line_num,
             CASE
                WHEN popr.action_code = 'APPROVE'
                AND prall.full_name <> 'Sudheer T. Paraputhra'
                AND grdpr.short_name < 'PS-10'
                AND poph.action_code = 'SUBMIT'
                   THEN TO_NUMBER (  TO_CHAR (  TO_DATE ('1', 'J')
                                              + (  poph.action_date
                                                 - popr.action_date
                                              'J'
                                   - 1
             END days_pr,
             poha.segment1 po_num, prall.full_name pr_approved_by,
             popr.action_date pr_approved_date,
             CASE
                WHEN poall_apprv.full_name <> 'Sudheer T. Paraputhra'
                AND grdpo_apprv.short_name < 'PS-10'
                AND poph_apprv.action_code = 'APPROVE'
                AND poph.action_code = 'SUBMIT'
                   THEN TO_NUMBER (  TO_CHAR (  TO_DATE ('1', 'J')
                                              + (  poph_apprv.action_date
                                                 - poph.action_date
                                              'J'
                                   - 1
             END days_po,
             popr.sequence_num pr_seq, popr.action_code pr_action,
             poall.full_name po_approved_by, poph.action_date po_approved_date,
             poph.sequence_num po_seq, poph.action_code po_action,
             poph_apprv.action_date po_approved_date_appr,
             poph_apprv.action_code apprv_action_code
        FROM po_requisition_headers_all porh,
             po_requisition_lines_all porl,
             po_req_distributions_all prda,
             po_distributions_all poda,
             po_headers_all poha,
             po_action_history popr,
             po_action_history poph,
             hr.per_all_people_f poall,
             hr.per_all_people_f prall,
             hr.per_all_assignments_f asgpo,
             hr.per_all_assignments_f asgpr,
             per_grades_vl grdpo,
             per_grades_vl grdpr,
             po_headers_all poha_apprv,
             po_distributions_all poda_apprv,
             po_action_history poph_apprv,
             hr.per_all_people_f poall_apprv,
             hr.per_all_assignments_f asgpo_apprv,
             per_grades_vl grdpo_apprv
       WHERE poph.employee_id = poall.person_id
         AND popr.employee_id = prall.person_id
         AND poall.person_id = asgpo.person_id
         AND prall.person_id = asgpr.person_id
         AND asgpr.grade_id = grdpr.grade_id(+)
         AND asgpo.grade_id = grdpo.grade_id(+)
         AND prda.distribution_id = poda.req_distribution_id
         AND poha.po_header_id = poda.po_header_id
         AND prda.requisition_line_id = porl.requisition_line_id
         AND porh.requisition_header_id = porl.requisition_header_id
         AND porh.requisition_header_id = popr.object_id
         AND poph.object_type_code = 'PO'
         AND poha.po_header_id = poph.object_id
         AND SYSDATE BETWEEN poall.effective_start_date AND poall.effective_end_date
         AND SYSDATE BETWEEN prall.effective_start_date AND prall.effective_end_date
         AND SYSDATE BETWEEN asgpo.effective_start_date AND asgpo.effective_end_date
         AND SYSDATE BETWEEN asgpr.effective_start_date AND asgpr.effective_end_date
         AND SYSDATE BETWEEN poall_apprv.effective_start_date
                         AND poall_apprv.effective_end_date
         AND SYSDATE BETWEEN asgpo_apprv.effective_start_date
                         AND asgpo_apprv.effective_end_date
         AND prda.distribution_id = poda_apprv.req_distribution_id
         AND poha_apprv.po_header_id = poda_apprv.po_header_id
         AND poph_apprv.employee_id = poall_apprv.person_id
         AND poall_apprv.person_id = asgpo_apprv.person_id
         AND asgpo_apprv.grade_id = grdpo_apprv.grade_id(+)
         AND poha_apprv.po_header_id = poph_apprv.object_id
         AND poph_apprv.object_type_code = 'PO'
    --AND PORH.SEGMENT1='6003' -------when i give a particular PR number it comes out correct even with the order by clause    
    AND poph_apprv.action_code = 'APPROVE'
    ORDER BY 4, 10, 14when the PORH.SEGMENT1 is commented in oorder to display days for all po/pr i get the error
    kindly help me
    or is there an alternate calculation to get the number of days
    my date is in the format of 4/29/2009 9:13:51 AM
    for my caluculation i ve just taken the dates as i require days only kindly help
    Edited by: makdutakdu on Jun 2, 2010 7:52 AM

  • ORA-1850: hor must be between 0 and 23 error

    Hi All
    i have the following table for creating and inserting i included only two fileds as these are the fields that i'm getting errors on.
    WITH     sample_data     AS
         SELECT     '50709' AS start_date, '2400' AS start_time  FROM dual     UNION ALL
         SELECT     '082510',              '0000'                  FROM dual
    SELECT       *
    FROM       sample_data
    ;DATA:
    START_DATE     START_TIME
    50709                        2400
    082510                        0000And now when i run the query against the table:
    SELECT   direction, car_count_pos, truck_count_pos,
             (car_count_pos + 2 * (truck_count_pos)) AS adjusted, car_count_neg,
             truck_count_neg,
             (car_count_neg + 2 * (truck_count_neg)) AS adjusted_neg,
             TO_DATE (start_date, 'MMDDYY') AS start_date,
             TO_DATE (end_date, 'MMDDYY') AS end_date,
             ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
                             'HH24.MI'
                   ) AS start_time,
             start_time,
             (TO_DATE (end_date, 'MMDDYY') - TO_DATE (start_date, 'MMDDYY')
             ) AS days
        FROM (SELECT   (CASE
                           WHEN t1.direction = '1'
                              THEN (  COUNT (t1.bin_1_data)
                                    + COUNT (t1.bin_2_data)
                                    + COUNT (t1.bin_3_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS car_count_pos,
                       t1.direction,
                       (CASE
                           WHEN t1.direction = '1'
                              THEN (  COUNT (t1.bin_4_data)
                                    + COUNT (t1.bin_5_data)
                                    + COUNT (t1.bin_6_data)
                                    + COUNT (t1.bin_7_data)
                                    + COUNT (t1.bin_8_data)
                                    + COUNT (t1.bin_9_data)
                                    + COUNT (t1.bin_10_data)
                                    + COUNT (t1.bin_11_data)
                                    + COUNT (t1.bin_12_data)
                                    + COUNT (t1.bin_13_data)
                                    + COUNT (t1.bin_14_data)
                                    + COUNT (t1.bin_15_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS truck_count_pos,
                       (CASE
                           WHEN t1.direction = '3'
                              THEN (  COUNT (t1.bin_1_data)
                                    + COUNT (t1.bin_2_data)
                                    + COUNT (t1.bin_3_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS car_count_neg,
                       (CASE
                           WHEN t1.direction = '3'
                              THEN (  COUNT (t1.bin_4_data)
                                    + COUNT (t1.bin_5_data)
                                    + COUNT (t1.bin_6_data)
                                    + COUNT (t1.bin_7_data)
                                    + COUNT (t1.bin_8_data)
                                    + COUNT (t1.bin_9_data)
                                    + COUNT (t1.bin_10_data)
                                    + COUNT (t1.bin_11_data)
                                    + COUNT (t1.bin_12_data)
                                    + COUNT (t1.bin_13_data)
                                    + COUNT (t1.bin_14_data)
                                    + COUNT (t1.bin_15_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS truck_count_neg,
                       t2.start_date, t2.start_time, t2.end_date, t2.end_time
                  FROM bin_data t1, traffic_sample t2
                 WHERE t1.traffic_sample_id = t2.traffic_sample_id
              GROUP BY t1.direction,
                       t2.start_date,
                       t2.start_time,
                       t2.end_date,
                       t2.end_time)
       WHERE direction IN ('1', '3')
    GROUP BY TO_DATE (start_date, 'MMDDYY'),
             direction,
             car_count_pos,
             truck_count_pos,
             (car_count_pos + 2 * (truck_count_pos)),
             truck_count_neg,
             (car_count_neg + 2 * (truck_count_neg)),
             TO_DATE (end_date, 'MMDDYY'),
             ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
                             'HH24.MI'
             start_time,
             car_count_negI'm getting the error
    ORA-1850: Hour must be between 0 and 23
    But as you see there is a value 2400 in the table is there any way to get around this? please need help.
    Thanks
    Edited by: thinkingeye on Aug 26, 2010 8:42 AM

    Thanks AP but i came up with something different which i guess sserved the same purpose i used the DECODE fucntion in the INNER query.
    SELECT   direction, car_count_pos, truck_count_pos,
             (car_count_pos + 2 * (truck_count_pos)) AS adjusted, car_count_neg,
             truck_count_neg,
             (car_count_neg + 2 * (truck_count_neg)) AS adjusted_neg,
             TO_DATE (start_date, 'MMDDYY') AS start_date,
             TO_DATE (end_date, 'MMDDYY') AS end_date,
             ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
                             'HH24.MI'
                   ) AS start_time,
                   ROUND (TO_CHAR (TO_DATE (LPAD (end_time, 4, '0'), 'HH24MI'),
                             'HH24.MI'
                   ) AS end_time,
             start_time,
             (TO_DATE (end_date, 'MMDDYY') - TO_DATE (start_date, 'MMDDYY')
             ) AS days,
             CITY,COUNTY,LOCATION,ROUTE_NBR,ROUTE_TYPE
        FROM (SELECT   (CASE
                           WHEN t1.direction = '1'
                              THEN (  COUNT (t1.bin_1_data)
                                    + COUNT (t1.bin_2_data)
                                    + COUNT (t1.bin_3_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS car_count_pos,
                       t1.direction,
                       (CASE
                           WHEN t1.direction = '1'
                              THEN (  COUNT (t1.bin_4_data)
                                    + COUNT (t1.bin_5_data)
                                    + COUNT (t1.bin_6_data)
                                    + COUNT (t1.bin_7_data)
                                    + COUNT (t1.bin_8_data)
                                    + COUNT (t1.bin_9_data)
                                    + COUNT (t1.bin_10_data)
                                    + COUNT (t1.bin_11_data)
                                    + COUNT (t1.bin_12_data)
                                    + COUNT (t1.bin_13_data)
                                    + COUNT (t1.bin_14_data)
                                    + COUNT (t1.bin_15_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS truck_count_pos,
                       (CASE
                           WHEN t1.direction = '3'
                              THEN (  COUNT (t1.bin_1_data)
                                    + COUNT (t1.bin_2_data)
                                    + COUNT (t1.bin_3_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS car_count_neg,
                       (CASE
                           WHEN t1.direction = '3'
                              THEN (  COUNT (t1.bin_4_data)
                                    + COUNT (t1.bin_5_data)
                                    + COUNT (t1.bin_6_data)
                                    + COUNT (t1.bin_7_data)
                                    + COUNT (t1.bin_8_data)
                                    + COUNT (t1.bin_9_data)
                                    + COUNT (t1.bin_10_data)
                                    + COUNT (t1.bin_11_data)
                                    + COUNT (t1.bin_12_data)
                                    + COUNT (t1.bin_13_data)
                                    + COUNT (t1.bin_14_data)
                                    + COUNT (t1.bin_15_data) * 0.981 * 1.019
                           ELSE NULL
                        END
                       ) AS truck_count_neg,
                       t2.start_date, t2.start_time, t2.end_date,*decode(t2.END_TIME,2400,'2359',t2.end_time) as end_time*,t3.CITY, t3.COUNTY,t3.LOCATION,t3.ROUTE_NBR, t3.ROUTE_TYPE
                  FROM bin_data t1, traffic_sample t2,location_details t3
                 WHERE t1.traffic_sample_id = t2.traffic_sample_id
                 and t2.TRAFFIC_SAMPLE_ID=t3.TRAFFIC_SAMPLE_ID
              GROUP BY t1.direction,
                       t2.start_date,
                       t2.start_time,
                       t2.end_date,
                       t2.end_time,
                       t3.CITY, t3.COUNTY,t3.LOCATION,t3.ROUTE_NBR, t3.ROUTE_TYPE)
       WHERE direction IN ('1', '3')
    GROUP BY TO_DATE (start_date, 'MMDDYY'),
             direction,
             car_count_pos,
             truck_count_pos,
             (car_count_pos + 2 * (truck_count_pos)),
             truck_count_neg,
             (car_count_neg + 2 * (truck_count_neg)),
             TO_DATE (end_date, 'MMDDYY'),
             ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
                             'HH24.MI'
             start_time,
             car_count_neg,
             end_time,
             CITY,COUNTY,LOCATION,ROUTE_NBR,ROUTE_TYPE

  • Error: ORA-01847: day of month must be between 1 and last day of month

    Hi,
    I am getting this ORA-01847: day of month must be between 1 and last day of month type of error but I have checked my data all are correct.
    I am inserting the data in the merge query. It is giving the above error.
    but when i insert the data like that
    insert into dt(start_date) select TO_DATE (tariff_start_date, 'DD/MM/RRRR') from ext_zpp0a871;
    It does not give any error.
    Please find the below code
    DECLARE
    l_sv_error_msg VARCHAR2 (1000);
    BEGIN
    FOR i IN (SELECT condition_type, sales_org, division_channel, division,
    price_list, ean_upc, amount, unit_of_measure1,
    tariff_start_date, tariff_end_date
    FROM ext_zpp0a871--This is external table
    WHERE condition_type = 'ZPP0' AND ROWNUM < 200)
    LOOP
    BEGIN
    MERGE INTO sap_tariff st
    USING (SELECT i.price_list pl, i.ean_upc upc,
    TO_DATE (i.tariff_start_date, 'DD/MM/RRRR') tsd,
    TO_DATE (i.tariff_end_date, 'DD/MM/RRRR') ted
    FROM DUAL) du
    ON (st.prod_ean_cuni = du.upc
    AND st.pricelist = du.pl
    AND st.tariff_start_date = du.tsd
    AND st.tariff_end_date = du.ted)
    WHEN MATCHED THEN
    UPDATE
    SET st.condition_type = i.condition_type,
    st.sales_org = i.sales_org,
    st.division_channel = i.division_channel,
    st.division = i.division,
    st.amount =
    TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
    st.uom = i.unit_of_measure1
    WHEN NOT MATCHED THEN
    INSERT (condition_type, sales_org, division_channel, division,
    pricelist, prod_ean_cuni, amount, uom,
    tariff_start_date, tariff_end_date)
    VALUES (i.condition_type, i.sales_org, i.division_channel,
    i.division, i.price_list, i.ean_upc,
    TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
    i.unit_of_measure1,
    TO_DATE (i.tariff_start_date, 'DD/MM/RRRR'),
    TO_DATE (i.tariff_end_date, 'DD/MM/RRRR'));
    /*INSERT INTO sap_tariff
    (condition_type, sales_org, division_channel,
    division, pricelist, prod_ean_cuni,
    amount,
    uom,
    tariff_start_date,
    tariff_end_date
    VALUES (i.condition_type, i.sales_org, i.division_channel,
    i.division, i.price_list, i.ean_upc,
    TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
    i.unit_of_measure1,
    TO_DATE (i.tariff_start_date, 'DD/MM/RRRR'),
    TO_DATE (i.tariff_end_date, 'DD/MM/RRRR')
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX
    THEN
    UPDATE sap_tariff
    SET condition_type = i.condition_type,
    sales_org = i.sales_org,
    division_channel = i.division_channel,
    division = i.division,
    amount =
    TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
    uom = i.unit_of_measure1;
    WHEN OTHERS
    THEN
    l_sv_error_msg := SQLERRM (SQLCODE);
    INSERT INTO sap_tariff_log
    (date_of_load, condition_type, sales_org,
    division_channel, division, price_list,
    prod_ean_cuni, amount, uom,
    tariff_start_date, tariff_end_date,
    rejection_reason
    VALUES (SYSDATE, i.condition_type, i.sales_org,
    i.division_channel, i.division, i.price_list,
    i.ean_upc, i.amount, i.unit_of_measure1,
    i.tariff_start_date, i.tariff_end_date,
    l_sv_error_msg
    END;
    END LOOP;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_sv_error_msg := SQLERRM (SQLCODE);
    neo_pro_log ('Others Error', l_sv_error_msg);
    END;

    user13400510 wrote:
    but when i insert the data like that
    insert into dt(start_date) select TO_DATE (tariff_start_date, 'DD/MM/RRRR') from ext_zpp0a871;
    It does not give any error.Maybe the error is on tariff_end_date instead of tariff_start_date ?
    What are the datatypes of tariff_start_date and tariff_end_date ? If they are already dates, and you to_date them (and depending on what your nls_date_xxxxx params are) you can have such errors :SQL> sho parameter nls_date_format
    NAME_COL_PLUS_SHOW_PARAM                 TYPE        VALUE_COL_PLUS_SHOW_PARAM
    nls_date_format                          string      DD/MM/YYYY
    SQL> select to_date(sysdate,'Day dd Mon RRRR') from dual;
    select to_date(sysdate,'Day dd Mon RRRR') from dual
    ERROR at line 1:
    ORA-01846: not a valid day of the week
    SQL> select to_date(sysdate,'hh24:mi:ss dd/mm/rrrr') from dual;
    select to_date(sysdate,'hh24:mi:ss dd/mm/rrrr') from dual
    ERROR at line 1:
    ORA-01850: hour must be between 0 and 23

  • ORA-01847: day of month must be between 1 and last day of month error

    Hi All
    When i run the following code i'm getting the error:ORA-01847: day of month must be between 1 and last day of month error
    SELECT t2.owner_cat,
    t1.owner_id,
    stock_id,
    Sum(received_amount) received_amount,
    Sum(curr_amount) curr_amount,
    Sum(used_amount) used_amount,
    To_char(Add_months(date_work,6),'YYYY') date_work
    FROM (SELECT owner_id_to owner_id,
    stock_id_to stock_id,
    Sum(full_amount) received_amount,
    0 curr_amount,
    0 used_amount,
    To_char(0) date_work
    FROM dw_wms_mat_transfer
    WHERE master_code_id IN ('8664','8665')
    GROUP BY owner_id_to,
    stock_id_to
    UNION ALL
    SELECT owner_id,
    stock_id,
    0 received_amount,
    Sum(curr_amount) curr_amount,
    0 used_amount,
    To_char(0) date_work
    FROM dw_wms_mat_inv
    WHERE master_code_id IN ('8664','8665')
    GROUP BY owner_id,
    stock_id
    UNION ALL
    SELECT t2.owner_id,
    t1.stock_id,
    0 received_amt,
    0 curr_amt,
    Sum(amount) used_amt,
    To_char(Add_months(date_work,6),'YYYY') date_work
    FROM dw_wms_wo_mat_dc t1,
    (SELECT owner_id,
    stock_id
    FROM dw_wms_mat_inv
    WHERE master_code_id IN ('8664','8665')
    GROUP BY owner_id,
    stock_id) t2
    WHERE t1.stock_id = t2.stock_id
    GROUP BY t2.owner_id,
    t1.stock_id,
    To_char(Add_months(date_work,6),'YYYY')) t1,
    dw_wms_setup_owner t2
    WHERE t1.owner_id = t2.owner_id
    GROUP BY t2.owner_cat,
    t1.owner_id,
    stock_id,
    To_char(Add_months(date_work,6),'YYYY')
    But when i just run the inner query:
    (SELECT owner_id_to owner_id,
    stock_id_to stock_id,
    Sum(full_amount) received_amount,
    0 curr_amount,
    0 used_amount,
    To_char(0) date_work
    FROM dw_wms_mat_transfer
    WHERE master_code_id IN ('8664','8665')
    GROUP BY owner_id_to,
    stock_id_to
    UNION ALL
    SELECT owner_id,
    stock_id,
    0 received_amount,
    Sum(curr_amount) curr_amount,
    0 used_amount,
    To_char(0) date_work
    FROM dw_wms_mat_inv
    WHERE master_code_id IN ('8664','8665')
    GROUP BY owner_id,
    stock_id
    UNION ALL
    SELECT t2.owner_id,
    t1.stock_id,
    0 received_amt,
    0 curr_amt,
    Sum(amount) used_amt,
    To_char(Add_months(date_work,6),'YYYY') date_work
    FROM dw_wms_wo_mat_dc t1,
    (SELECT owner_id,
    stock_id
    FROM dw_wms_mat_inv
    WHERE master_code_id IN ('8664','8665')
    GROUP BY owner_id,
    stock_id) t2
    WHERE t1.stock_id = t2.stock_id
    GROUP BY t2.owner_id,
    t1.stock_id,
    To_char(Add_months(date_work,6),'YYYY'))
    I'm not getting that error, any help please?

    Hi,
    Like Anuraq already explained, you need to keep in mind that when you apply a to_char, you've turned your DATE datatype into a STRING and by doing that you've lost the ability to use the add_months function again in your outer query.
    Using a simplified example, extracted from your example:
    MHO%xe> select to_char(add_months(date_work, 6), 'yyyy') date_work
      2  from ( select to_char(0) date_work
      3         from dual
      4         union all
      5         select to_char(0) date_work
      6         from dual
      7         union all
      8         select to_char(add_months(sysdate, 6), 'yyyy') date_work
      9         from dual
    10       );
    select to_char(add_months(date_work, 6), 'yyyy') date_work
    FOUT in regel 1:
    .ORA-01847: day of month must be between 1 and last day of monthHowever, you should either do something like:
    MHO%xe> select nvl(to_char(add_months(date_work, 12), 'yyyy'), '0') date_work
      2  from ( select to_date(null) date_work
      3         from dual
      4         union all
      5         select to_date(null) date_work
      6         from dual
      7         union all
      8         select sysdate date_work
      9         from dual
    10       );
    DATE
    0
    0
    2010or (less clear, more confusing):
    MHO%xe> select nvl(to_char(add_months(date_work, 6), 'yyyy'), '0') date_work
      2  from ( select to_date(null) date_work
      3         from dual
      4         union all
      5         select to_date(null) date_work
      6         from dual
      7         union all
      8         select add_months(sysdate, 6) date_work
      9         from dual
    10       );
    DATE
    0
    0
    2010It's not clear to me why you're using add_months twice (inner + outer query) in your original example.
    As you can see you can get the same results using it only once in your outer query.

  • ORA-01850: hour must be between 0 and 23

    Hi techies,
    We have created a procedure for our daily report.its running fine for two location.when we run for a location we end up with this error.our current NLS_DATE_FORMAT is HH24:MI:SS.but its running successfully when we set nls_date_format='DD-MON-YY'.whereas other two (Which is same except a table from where it fetch data thru dblink) running properly with NLS_DATE_FORMAT is HH24:MI:SS.
    ORA-01850: hour must be between 0 and 23
    ORA-02063: preceding line from DW_TO_DIRC.NACALOGISTICS.COM
    ORA-06512: at "OTSLGWEB.DAILY_JOB_PROFIT_REPORT_USA", line 89
    ORA-06512: at line 1

    Hi Techie,
    Apologies for my vague post.
    Here it would be clear.
    My database NLS_DATE_FORMAT='HH24:MI:SS'
    We have three procedure one is for AUSTRALIA,NEW ZEALAND and USA for daily report.all three are SAME CODE except a view whice is used inside the procedure from where these procedures get data thru dblink and create table in local database.
    when i execute procdure for AUSTRALI AND NEW ZEALAND it was successfull whereas when i execute for USA it was failing with the error i above mentioned.
    if I set
    alter session set nls_date_format='DD-MON-YY';
    and execute the USA Procedure it was successfully completing.
    My question here is..
    1.What was the real cause of this error?
    2.if NLS settings are wrong.how the same code of AUSTRALIA AND NEW ZEALAND is successfull?
    3.Can we add 'alter session set NLS_DATE_FORMAT='DD-MON-YY' inside the procedure? (We do not have approval to change this in DB level so we intend to add it in session level)
    4.is it caused due to data?
    Cheers
    Sameer Ameen

  • Day must be between 1 and last day of month

    Hi
    I have a master detail form for overtime entries.
    Master Block contain emp_no,name,month etc.
    Detail block contain a date field ,,from time, to time etc
    when i enter the date in detail block it defaults the month from Server date and i am getting the error "Day must be between 1 and last day of ...."
    The form is going to reside on server so i cant go for changing system date for that.
    THe work around i am trying is i have created a dummy item in detail block for Date(dd) entry and populating my original date field on the basis of it.
    so that i can get rid of last day validation of month.The datatype of dummy item is char
    my code is
    c_day varchar(2);
    c_month varchar(2);
    c_year varchar(4);
    d_date varchar(8);
    begin
    c_day := :DETAIL.dummy;
    c_month := to_char(:MASTER.month, 'mm');
    c_year := to_char(:master.month, 'yyyy');
    d_date := c_day||c_month||c_year;
    :DETAIL.ot_date := to_date(d_date,'ddmmyyyy');
    end;
    I am using post change trigger on my dummy item but i am getting ORA-01840 for that.I have tried several ways but it is giving different type of date errors for that.
    Any help is highly appreciated

    Dear try this
    SELECT RUN_NUM, CV AS MONTH_DATE
    FROM
    SELECT ROWNUM AS RUN_NUM,TO_DATE('01-' || 'SEP' || '-' || 2007 ,'DD/MM/YYYY')+ (ROWNUM-1) CV
    FROM
    (SELECT 1 FROM DUAL GROUP BY CUBE (1,1,1,1,1)) A
    WHERE TO_CHAR(CV,'MON-YYYY') = 'SEP-2007'

  • Frm-50004: day must be between 1 and last of month.

    frm-50004: day must be between 1 and last of month.
    hi dear all,
    I HAVE A TEXTITEM OF DATATYPE DATE. ITS FORMAT MASK IS 'HH24-MI-SS AM' BUT
    WHEN I TRY TO INSERT IT GIVES THE FOLLOWING ERROR:
    FRM-50004: Day must be between 1 and last of month.
    thanks
    Muhammad Nadeem
    Mardan (Pakistan)
    [email protected]

    I don't think you are getting that error message from that date item. Oracle defaults the month to current month, day to 01, and year to current year when they aren't entered in a date.
    However, you cannot use 'HH24' with the 'AM' meridian indicator, so that format mask is illegal, and SHOULD generate a different error message.
    And last, if you want Forms to carry the time in a date field, you MUST set the datatype to datetime.

  • Crystal preview - A subscript must be between 1 and the size of the array..

    Hi
    I am getting the following error when I run Print Preview on the CR Sales Invoice:
    "A subscript must be between 1 and the size of the array ........."
    Any ideas?
    Thanks
    Ian

    Thanks Gordon
    However this is a fresh install and the default Crystal SI layout provided by SAP and I would have expected it to work.  It makes it seem like an installation problem.
    Do you know where the *.rpt files as stored by SAP and where I could maybe get a new Crystal SI to test?
    Thanks

  • Hour must be between 1 and 12

    UPDATE ATTENDENCE SET OUTTIME=TO_TIMESTAMP('" + attendence.getLeaveTime() + "','HH:MI AM') WHERE EMPID='" + attendence.getEmpID() + "' AND ATTENDENCEDATE=to_date('" + attendence.getDate() + "','YYYY-MM-DD')
    attendence.getLeaveTime's return type is Time Stamp. I got error "hour must be between 1 and 12". I passed time stamp like this. setLeaveTime(new Timestamp(inTime.getTime()))
    Edited by: 993001 on Mar 24, 2013 9:47 AM

    CREATE TABLE "ELAMOR"."ATTENDENCE"
    (     "ATTENDENCEID" VARCHAR2(20 BYTE) NOT NULL ENABLE,
         "INTIME" TIMESTAMP (6) NOT NULL ENABLE,
         "OUTTIME" TIMESTAMP (6) NOT NULL ENABLE,
         "EMPID" VARCHAR2(20 BYTE) NOT NULL ENABLE,
         "ATTENDENCEDATE" DATE,
         CONSTRAINT "ATTENDENCE_PK" PRIMARY KEY ("ATTENDENCEID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "USERS" ENABLE,
         CONSTRAINT "ATTENDENCE_EMPLOYEE_FK1" FOREIGN KEY ("EMPID")
         REFERENCES "ELAMOR"."EMPLOYEE" ("EMPID") ON DELETE CASCADE ENABLE
    ) SEGMENT CREATION IMMEDIATE
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "USERS" ;

  • Object name must have between 000003 and 000009 characters

    Hi BW Experts,
    When I am trying to create a cube I am getting the below error message:
    Object name Z0FIGL_01 must have between 000003 and 000009 characters. Message no. R7112
    It would be great if some one can help me to resolve the issue...
    Regards,
    Reddy

    Hi
    The infocube technical name must be in between 3 to 9 characteristics length
    i.e,Min 3 Char & Max 9 Char
    is ZOFIGL_01 is ur object name ?its defined within limits,need to verify:)
    hope this helps
    Sriman
    Edited by: Sreeman on Apr 11, 2008 9:34 PM

  • How to see themes on full page of firefox like chrome and not only on the top bar

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/876505]]</blockquote>
    how to see themes on full page of firefox like chrome and not only on the top bar

    Personas or Lightweight Themes are the ones that just put a background on the toolbars.
    You can look for the real (original style) themes here:
    : https://addons.mozilla.org/en-US/firefox/themes/
    :and you should be able to easily identify them by their pictures. I would suggest that you pick a theme that is identified under the version information to also run in Firefox 8, so you will be able to continue when you upgrade to 6.0.2 and above.
    I am on 6.0.2 and I would be shown 450 themes.
    Another method is to install a style using the "Stylish" extension, specifically a global style is what you are interested in. There are 3,697 global styles which is one [http://userstyles.org/categories category] of styles. Styles are not programs but you can put up a background picture of your choosing or color areas. But instead of hundreds to choose from you have thousands and they are mostly variations of another style. One advantage of a style is that you can modify a style to suit yourself with little or no programming experience.
    : http://userstyles.org/styles/browse/global

  • What is the difference between Never and Not supported

    What is the difference between Never and Not supported?
    Also I want to know what are all the transaction attibutes are supported by MDB and why?

    Never- If the bean is called in an existing trasaction an exception is thrown.
    NotSupported - Methods always execute outside the transaction context. If a transaction is started when this method is called, this method is executed outside the transaction. The initial transaction is continued after the method exits.

Maybe you are looking for

  • Photoshop CS2 has begun crashing. Can't identify what changes I have made may have started this. I a

    Photoshop CS2 has begun crashing. Can't identify what changes I have made may have started this. I am using a MacBook Pro (2.2 GHz Intel Core i7) running OS 10.6.8. The error message reads: Process:         Adobe Photoshop CS2 [8011] Path:           

  • Get the  value and pass it to child jsp page

    Hi All, I want to get the attribute value from the adf table in my parent jsp page and again send it to the child jsp page.I'm very new to adf.Please any body give me a example for this.Please help me. Thanks in advance!

  • Gui xalan xml

    I am trying to program a java swing gui with one button that will transform old.xml to new.xml using transform.xsl using xalan but the compiler gives an error message: Transform2.java:53: unreported exception javax.xml.transform.TransformerException;

  • Has anyone tried running Dragon NaturallySpeaking (for Windows) on Mac Mavericks?

    Has anyone tried running Dragon NaturallySpeaking (for Windows) on Mac Mavericks? I have finally given up on Dragon Dictate for Mac, which alas, after years of buying every new updated version, is still exceedingly buggy and does not begin to compare

  • BRM,BRF and BRFPLUS

    Hi, I am new to BRM,BRF and BRFPLUS. Can you please let me know the following 1.Exact difference between BRM and BRF/BRFPLUS and between BRF and BRFPLUS? 2.Any documents for basic concepts for all these having the explanation of basic things used lik