Strange invalid month error.
Hi all,
I have a function which receives a date and then returns a text string saying what day of the week it is, ie Monday Tuesday etc etc
For example sakes I'll say the function is called dayoftheweek and we use the function like 'select somedate, dayoftheweek(somedate) from dual'
Now, the bit within the function that works out the day is as below
SELECT TO_CHAR(TO_DATE(p_date, 'DD/MM/RRRR') ,'DAY') from dual (p_date is the internal function variable for the date passed in.)
Now, if I do this
select dayoftheweek('25-MAY-09') from dual -- this works.
But...
select dayoftheweek('25/05/09') from dual -- this does not work, I get an ora 01843 invalid month error.
So, I assumed it was something to do with the logic that worked out the day of the week.
However, the below works.
SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR') ,'DAY') from dual
Does anyone know why when passing a date to the function in format 'select dayoftheweek('25/05/09') from dual' does not work but if I use this format within the function logic as above it does work?
Cheers,
rg
Hello,
Oracle does not know your date format:
select dayoftheweek('25/05/09')I.e, it does not know that the date you are passing in is in the form of 'DD/MM/MM'. You must tell it (since it isn't your default format):
select dayoftheweek(to_date('25/05/09', 'DD/MM/YY'))If all you wanted, however, was the day of the week from a date, then:
TO_CHAR(to_date('25/05/09', 'DD/MM/YY'), 'DAY')Will give you that.
And by the way, this:
SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR') ,'DAY') from dualIs correct by chance, even though you're getting no error you may get the wrong result, because you're telling oracle you're passing in 4 digits for the year, yet you're only passing in two.
Edit Beware:
SQL> SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR'), 'YYYY') from dual;
TO_C
2009
SQL> SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/YYYY'), 'YYYY') from dual;
TO_C
0009
Similar Messages
-
Invalid month error sometimes in SQL Developer
Hi
sometimes I get 'Invalid Month error' in SQL developer when I execute the following query
select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual;
But when I dosconnect session and reconnect, It works fine
Any suggestions on how to avoid this issue ?
Thanks872202 wrote:
Hi
sometimes I get 'Invalid Month error' in SQL developer when I execute the following query
select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual;
But when I dosconnect session and reconnect, It works fine
Any suggestions on how to avoid this issue ?
ThanksThere's absolutely no reason that that should result in that error.
The SQL is sent to the database and it's perfectly valid SQL, taking a string, and converting it to a date with the correct date format mask, and then truncating the date (which, by default is to the day, which in this case is pointless as it's already truncated), returning a DATE datatype, which SQL Developer will then render using it's date display format. -
Invalid month error in WEBI report level
Hi,
I had a issue with date format.I am using oracle10g as a backend database.I have a date object in universe level i used that object in web intelligence report level.I created prompt for date object after select the date from the list i am getting " invalid month error". In database level object datatype is timestamp.
How to solve this issue.can somebody help me to solve the problem.Hi
Date Objects depends on various formats for different database
Make sure that u format date like MM/dd/yyyy in universe level . and the object should be in date datatype .
In the query level use prompt to select dates.
In report level
create a variable and use a formula like
todate(userresponse("Enter date");"")
Hope this helps U
Sunil -
Invalid Month error in PL/SQL
Hi,
The below query if given without the -- lines at an SQL prompt with work fine. But when used with in a PL/SQL will not work. It throws:
sqlcode: -1843,sqlerrm: ORA-01843: not a valid month error.
SELECT
to_char(wk_beg_d,'dd/mm/yyyy'),to_char(wk_end_d,'dd/mm/yyyy')
-- INTO
-- v_fis_wk_strt_d,
-- v_fis_wk_end_d
FROM
acct_date
WHERE
acct_d = '12-APR-07;
Any suggestions will be very helpful.
Thanks,
Ravi.It reall depends on what you will be doing with v_fis_wk_strt_d and v_fis_wk_end_d.
If you are just going to display them, and need to have that format for display purposes, then
DECLARE
v_fis_wk_strt_d VARCHAR2(11);
v_fis_wk_end_d VARCHAR2(11);
BEGIN
SELECT TO_CHAR(wk_beg_d,'dd/mm/yyyy'), TO_CHAR(wk_end_d,'dd/mm/yyyy')
INTO v_fis_wk_strt_d, v_fis_wk_end_d
FROM acct_date
WHERE acct_d = TO_DATE('12-APR-2007', 'dd-mon-yyyy');
END;If you are need to use them later as "real" dates, then, as Boneist suggested:
DECLARE
v_fis_wk_strt_d DATE;
v_fis_wk_end_d DATE;
BEGIN
SELECT wk_beg_d, wk_end_d
INTO v_fis_wk_strt_d, v_fis_wk_end_d
FROM acct_date
WHERE acct_d = TO_DATE('12-APR-2007', 'dd-mon-yyyy');
END;John -
I have seen a thread on this topic. But my issue is a bit different.
I have a table (suppose A) with a date column (let b B)
There is a view on this table say A_V. This view simply queries the table A.
I have another table C, to which I am inserting record from A_V in a for loop like
FOR i IN (SELECT * FROM A_V)
LOOP
INSERT INTO C(x,y,B)
VALUES( i.x,i.y,nvl(i.B,sysdate) );
END LOOP;
I found invalid month issue in it. I am not sure of the reason. However, do I need apply to_char on i.B or nvl(i.B,sysdate) to give it a specific format. And if so, how would I know what format I should apply.
I was also doing some test plsql developer and found result like this. Can anyone help me understand.
select id,nvl(to_char(DATE_DATA,'dd/MM/yyyy'),to_date('19000101','YYYYMMDD')) from DATA_DUMP
where DATE_DATA is null
result is
1 361725 01-JAN-00
2 800001 01-JAN-00
3 800002 01-JAN-00
4 420068 01-JAN-00
5 442682 01-JAN-00
6 442984 01-JAN-00
7 442340 01-JAN-00
select id,nvl(DATE_DATA,to_date('19000101','YYYYMMDD')) from DATA_DUMP
where DATE_DATA is null
1 361725 1/1/1900
2 800001 1/1/1900
3 800002 1/1/1900
4 420068 1/1/1900
5 442682 1/1/1900
6 442984 1/1/1900
7 442340 1/1/1900
I get similar result with DATA_DATA not null too.
-Debp.s. you also don't need to do your insert as single inserts within a cursor loop as this will give you poor performance. It should be done as a single insert... select... statement.
e.g.
SQL> select * from a;
EMPNO DEPTNO B
7369 20 17/12/1980 00:00:00
7499 30 20/02/1981 00:00:00
7521 30 22/02/1981 00:00:00
7566 20 02/04/1981 00:00:00
7654 30 28/09/1981 00:00:00
7698 30 01/05/1981 00:00:00
7782 10 09/06/1981 00:00:00
7788 20
7839 10 17/11/1981 00:00:00
7844 30 08/09/1981 00:00:00
7876 20
7900 30 03/12/1981 00:00:00
7902 20 03/12/1981 00:00:00
7934 10 23/01/1982 00:00:00
14 rows selected.
SQL> create table c (empno number, deptno number, b date);
Table created.
SQL> insert into c
2 select empno, deptno, nvl(b,sysdate)
3 from a;
14 rows created.
SQL> select * from c;
EMPNO DEPTNO B
7369 20 17/12/1980 00:00:00
7499 30 20/02/1981 00:00:00
7521 30 22/02/1981 00:00:00
7566 20 02/04/1981 00:00:00
7654 30 28/09/1981 00:00:00
7698 30 01/05/1981 00:00:00
7782 10 09/06/1981 00:00:00
7788 20 09/01/2009 15:24:04
7839 10 17/11/1981 00:00:00
7844 30 08/09/1981 00:00:00
7876 20 09/01/2009 15:24:04
7900 30 03/12/1981 00:00:00
7902 20 03/12/1981 00:00:00
7934 10 23/01/1982 00:00:00
14 rows selected.
SQL> -
Invalid month error during import
I have set NLS_DATE_FORMAT=”YYYY-MM-DD HH24:MI:SS’ in my import script, yet I get following error in import. I tried NLS_DATE_FORMAT=”RRRR-MM-DD HH24:MI:SS” as well, yet get same error. How can I get rid of the error.
I am on Oracle 10.2.0.4 on HP UNIX.
" ALTER TABLE "IN_ERM_SPOOL" MODIFY ("REPORT_TIME" DEFAULT '1970-01-01 00:00"
":00' )"
IMP-00003: ORACLE error 1843 encountered
ORA-01843: not a valid month
IMP-00017: following statement failed with ORACLE error 1843:
" ALTER TABLE "IN_EXTERN_MSG" MODIFY ("START_TIME" DEFAULT '1970-01-01 00:00"
":00' )"
IMP-00003: ORACLE error 1843 encountered
ORA-01843: not a valid monthThat was a typo. Double quotes are needed in shell script.I am sorry to see that COPY & PASTE is broken for you.
Post results of
SELECT * from v$version;
I am NOT convinced that setting OS environmental variable has the desire results
bcm@bcm-laptop:~$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
bcm@bcm-laptop:~$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 20 19:52:55 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select sysdate from dual;
SYSDATE
20-NOV-10
SQL> alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';
Session altered.
SQL> select sysdate from dual;
SYSDATE
2010-11-20 20:17:34
SQL> -
Call procedure with Spring and strange invalid index error.
Hi I call a procedure, from java in this way:
FlussiGiornalieriStoredProcedure proc = new FlussiGiornalieriStoredProcedure(dataSource);
String column_order="";
if (orderColumn!=null) {
column_order = orderColumn + " " + orderType;
} else {
column_order = " stato DESC "; //this is the invalid index column of the error
Map mappa = proc.execute(idGruppo, dataInizio, dataFine, startRow, endRow, column_order);
result = (List<VistaFlussiGiornalieri>) mappa.get("recordsetCursor");
numeroTotaleRighe = ((BigDecimal)mappa.get("countRow")).intValue();
response.setSize(numeroTotaleRighe);
response.setList((List<VistaFlussiGiornalieri>) result);
private class FlussiGiornalieriStoredProcedure extends StoredProcedure {
private static final String SQL = "mkt_flussi_giornalieri2";
public FlussiGiornalieriStoredProcedure(DataSource ds) {
super(ds, SQL);
declareParameter(new SqlParameter("idGruppo", Types.VARCHAR));
declareParameter(new SqlParameter("dataInizio", Types.DATE));
declareParameter(new SqlParameter("dataFine", Types.DATE));
declareParameter(new SqlParameter("startRow", OracleTypes.NUMBER));
declareParameter(new SqlParameter("endRow", OracleTypes.NUMBER));
declareParameter(new SqlParameter("column_order", OracleTypes.VARCHAR));
//declareParameter(new SqlParameter("order_name", OracleTypes.VARCHAR));
declareParameter(new SqlOutParameter("recordsetCursor", OracleTypes.CURSOR, VistaFlussiGiornalieriDaoImpl.this));
declareParameter(new SqlOutParameter("countRow", OracleTypes.NUMBER, VistaFlussiGiornalieriDaoImpl.this));
//declareParameter(new SqlOutParameter("QUERY_STM", OracleTypes.VARCHAR, VistaFlussiGiornalieriDaoImpl.this));
compile();
public Map execute(String idGruppo, Date dataInizio, Date dataFine, int startRow, int endRow, String column_order) {
Map inputs = new HashMap();
inputs.put("idGruppo", idGruppo);
inputs.put("dataInizio", dataInizio);
inputs.put("dataFine", dataFine);
inputs.put("startRow", startRow);
inputs.put("endRow", endRow);
inputs.put("column_order", column_order);
return execute(inputs);
}When The java class call the oracle procedure I receive this message:
>
Caused by: java.sql.SQLException: Invalid index column
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:385)
at it.edison.markettracker.dao.spring.VistaFlussiGiornalieriDaoImpl.mapRow(VistaFlussiGiornalieriDaoImpl.java:155)
at it.edison.markettracker.dao.spring.VistaFlussiGiornalieriDaoImpl.mapRow(VistaFlussiGiornalieriDaoImpl.java:1)
at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
at org.springframework.jdbc.core.JdbcTemplate.processResultSet(JdbcTemplate.java:1124)
at org.springframework.jdbc.core.JdbcTemplate.extractOutputParameters(JdbcTemplate.java:1085)
at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:997)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:936)
... 26 more
If I call the procedure, from toad, in this way:
SET serveroutput ON
DECLARE
TROVATI SYS_REFCURSOR;
NUMERO_TROVATI NUMBER;
BEGIN
DBMS_OUTPUT.ENABLE(30000);
dbms_output.put_line('INIZIO');
Mkt_Flussi_Giornalieri2(1, trunc(sysdate), trunc(sysdate), 100, 50, 'stato DESC', TROVATI, NUMERO_TROVATI);
dbms_output.put_line('RECORD TROVATI:'||NUMERO_TROVATI);
END; I don't receive any error message. Why?
The procedure is:
CREATE OR REPLACE PROCEDURE Mkt_Flussi_Giornalieri2
( idGruppo IN VARCHAR2
, dataInizio IN DATE
, dataFine IN DATE
, startRow IN NUMBER
, endRow IN NUMBER
, column_order in varchar2
--, order_name in varchar2
, recordsetCursor OUT SYS_REFCURSOR
, countRow OUT NUMBER
) IS
order_clause varchar2(200) := ' ';
sql_stm varchar2(32000);
BEGIN
IF column_order IS NOT NULL
THEN
order_clause := column_order;
ELSE
order_clause := ' stato DESC ';
END IF;
dbms_output.put_line('clausola:'||order_clause);
sql_stm:='
SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
stato, dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
exec_seq, provider_description, log_info FROM
(SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
stato, dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
exec_seq, provider_description, log_info FROM
(SELECT
temp.flow_id AS idFlusso,
MKT_FLOW.flow_id || '' - '' || MKT_FLOW.flow_description || ''('' || temp.exec_seq || '')'' AS descrizioneFlusso,
TO_DATE(temp.date_id,''yyyymmddhh24miss'') AS dataRiferimento,
TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''dd/mm/yyyy'')||'' h. ''||TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''hh24:mi'') AS strDataRiferimento,
temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
mp.provider_link, mfc.log_info
FROM (
SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
FROM (
SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
FROM mkt_flow_conf_view fc
WHERE TRUNC(end_time) >= :1
AND TRUNC(end_time) <= :2
) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
WHERE v.exec_seq = v.exsq
AND e.fk_exec_seq (+) = v.exec_seq
AND tr.fk_exec_seq (+) = v.exec_seq
AND er.error_id (+) = e.error_code
) temp
INNER JOIN MKT_FLOW
ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
LEFT OUTER JOIN
(SELECT DISTINCT flow_id, log_info
FROM mkt_flow_conf) mfc
ON mkt_flow.flow_id = mfc.flow_id
, mkt_provider mp
WHERE NVL(error_id, -1) = NVL(eid, -1)
AND NVL(trace_id, -1) = NVL(tid, -1)
AND MKT_FLOW_GROUP.group_id=:3
AND NVL (mkt_flow.fk_provider_id, '' '') =
NVL (mp.provider_id, '' '') )
WHERE ROWNUM <= :4
MINUS
(SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
stato, dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
exec_seq, provider_description, log_info FROM
(SELECT
temp.flow_id AS idFlusso,
MKT_FLOW.flow_id || '' - '' || MKT_FLOW.flow_description || ''('' || temp.exec_seq || '')'' AS descrizioneFlusso,
TO_DATE(temp.date_id,''yyyymmddhh24miss'') AS dataRiferimento,
TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''dd/mm/yyyy'')||'' h. ''||TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''hh24:mi'') AS strDataRiferimento,
temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
mp.provider_link, mfc.log_info
FROM (
SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
FROM (
SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
FROM mkt_flow_conf_view fc
WHERE TRUNC(end_time) >= :5
AND TRUNC(end_time) <= :6
) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
WHERE v.exec_seq = v.exsq
AND e.fk_exec_seq (+) = v.exec_seq
AND tr.fk_exec_seq (+) = v.exec_seq
AND er.error_id (+) = e.error_code
) temp
INNER JOIN MKT_FLOW
ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
LEFT OUTER JOIN
(SELECT DISTINCT flow_id, log_info
FROM mkt_flow_conf) mfc
ON mkt_flow.flow_id = mfc.flow_id
, mkt_provider mp
WHERE NVL(error_id, -1) = NVL(eid, -1)
AND NVL(trace_id, -1) = NVL(tid, -1)
AND MKT_FLOW_GROUP.group_id=:7
AND NVL (mkt_flow.fk_provider_id, '' '') =
NVL (mp.provider_id, '' '') )
WHERE ROWNUM <= :8
) ) ORDER BY :9' ;
dbms_output.enable(30000);
dbms_output.put_line(sql_stm);
OPEN recordsetCursor FOR sql_stm USING dataInizio, dataFine, idGruppo, endRow, dataInizio, dataFine, idGruppo, startRow, order_clause;
SELECT COUNT(*) INTO countRow FROM
(SELECT
temp.flow_id AS idFlusso,
MKT_FLOW.flow_id || ' - ' || MKT_FLOW.flow_description || '(' || temp.exec_seq || ')' AS descrizioneFlusso,
TO_DATE(temp.date_id,'yyyymmddhh24miss') AS dataRiferimento,
TO_CHAR(TO_DATE(temp.date_id,'yyyymmddhh24miss'),'dd/mm/yyyy')||' h. '||TO_CHAR(TO_DATE(temp.date_id,'yyyymmddhh24miss'),'hh24:mi') AS strDataRiferimento,
temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
mp.provider_link, mfc.log_info
FROM (
SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
FROM (
SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
FROM mkt_flow_conf_view fc
WHERE TRUNC(end_time) >= dataInizio
AND TRUNC(end_time) <= dataFine
) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
WHERE v.exec_seq = v.exsq
AND e.fk_exec_seq (+) = v.exec_seq
AND tr.fk_exec_seq (+) = v.exec_seq
AND er.error_id (+) = e.error_code
) temp
INNER JOIN MKT_FLOW
ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
LEFT OUTER JOIN
(SELECT DISTINCT flow_id, log_info
FROM mkt_flow_conf) mfc
ON mkt_flow.flow_id = mfc.flow_id
, mkt_provider mp
WHERE NVL(error_id, -1) = NVL(eid, -1)
AND NVL(trace_id, -1) = NVL(tid, -1)
AND MKT_FLOW_GROUP.group_id=idGruppo
AND NVL (mkt_flow.fk_provider_id, ' ') =
NVL (mp.provider_id, ' '));
END Mkt_Flussi_Giornalieri2;
/Please, could someone help me?
Thanks. Bye Bye.Hi,
I have solved the problem, I forgot a parameter in the select, so java tells the an error. But now I have another problem. The procedure doesn't execute the order by. I pass the couple column_name order_type in a string as ("provider_description desc") dinamically but the procedure doesn't execute the ordering. Why?
Thanks, bye bye. -
Invalid Month error in stored procedure
Hello, I have a simple stored procedure that I pass a begin and end date into and it is complaining about the date formatting. Below is the table layout and stored procedure in question. How can I format the date for example as MM-DD-YYYY and not have it complain? I have tried using TO_DATE and TO_CHAR and it still complains.
Thank you.
-- Table
CREATE TABLE INV_MOVE_ARCHIVE
*( "RETAILER_ID" NUMBER NOT NULL,*
*"SKU_ID" VARCHAR2(18 BYTE) NOT NULL,*
*"OUTLET_ID" VARCHAR2(20 BYTE) NOT NULL,*
*"QTY_CHANGE" NUMBER NOT NULL,*
*"TRANS_DATE" DATE DEFAULT sysdate*
-- Stored procedure
CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
IS
skuId VARCHAR(18);
outletId VARCHAR(20);
qtyChange INTEGER;
-- Declaring the cursor
CURSOR getInvRecord IS
SELECT
sku_id,
outlet_id,
qty_change
INTO
skuId,
outletId,
qtyChange
FROM
inv_move_archive
WHERE
retailer_id = retailerId AND
trans_date >= beginDate AND
trans_date <= endDate;
BEGIN
FOR rec_getInvRecord IN getInvRecord LOOP
UPDATE OUTLET_SKU_XREF
SET qty = qty + qtyChange
WHERE outlet_id = outletId
AND sku_id = skuId;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
IF getInvRecord%isopen THEN CLOSE getInvRecord;
END IF;
END inv_move_update;
*/*Okay, I do not wantto change the table. I believe thatthe Java developers will need to change their code to call this procedure correctly. Another iss I am having is when I call this procedure manually from the database is is NOT doing the update. I put some debug statements in it and they indicate that the update statement is NOT updating any rows. If I run the select statement that is in the sp using the same parameters I pass into the sp it comes back with 1 row. The row to be updated is present in the table being updated.
-- Here is my sp call
DECLARE
BEGINDATE DATE;
ENDDATE DATE;
RETAILERID NUMBER;
BEGIN
BEGINDATE := to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS');
ENDDATE := to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS');
RETAILERID := 104;
INV_MOVE_UPDATE(
BEGINDATE => BEGINDATE,
ENDDATE => ENDDATE,
RETAILERID => RETAILERID
END;
-- Select statement with same values
SELECT
sku_id,
outlet_id,
qty_change
FROM
inv_move_archive
WHERE
retailer_id = 104 AND
trans_date >= to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS') AND
trans_date <= to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS')
-- Results from select
036266579804040 9900165 500
-- Here is the procedure with the debug statements in it.
CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
IS
skuId VARCHAR(18);
outletId VARCHAR(20);
qtyChange NUMBER;
errorMessage VARCHAR(2500) := NULL;
-- Declaring the cursor
CURSOR getInvRecord IS
SELECT
sku_id,
outlet_id,
qty_change
INTO
skuId,
outletId,
qtyChange
FROM
inv_move_archive
WHERE
retailer_id = retailerId AND
trans_date >= beginDate AND
trans_date <= endDate;
BEGIN
FOR rec_getInvRecord IN getInvRecord LOOP
DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
UPDATE OUTLET_SKU_XREF
SET qty = qty + qtyChange
WHERE outlet_id = outletId
AND sku_id = skuId;
DBMS_OUTPUT.PUT_LINE('SKUID: ' || skuId);
DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
errorMessage := 'Error updating the OUTLET_SKU_XREF table: ' || SQLCODE || ':' || SQLERRM;
RAISE_APPLICATION_ERROR(-20001,errorMessage);
DBMS_OUTPUT.PUT_LINE(errorMessage);
IF getInvRecord%isopen THEN CLOSE getInvRecord;
END IF;
END inv_move_update;
/I get no errors when running it. The DBMS_OUTPUT shows null for the skuId and 0 for Rows Updated. Like I said I ran the select manually and it returns a row and I see that the row does exist in the target table. Any ideas what is going on here?
Thank you
-- David -
Given query giving an error -invalid month????
select to_date(add_months(trunc(sysdate),-5) ||' 10:30:00 AM','mm/dd/yyyy hh:mi:ss am') from dual
giving an error-invalid month..1. Instead of comma you have put dot.
2. Below is teh correct usage
select to_date(to_char(add_months(trunc(sysdate),-5),'DD/MM/YYYY')||' 10:30:00 AM','DD/MM/YYYY HH:MI:SS AM')
from dual3. But, why are you going for this when there is a straight forward way? -
Case When Statement and ORA:01722 Invalid number error
Hi folks, I have posted this under another heading as well under E-business suite so apologies if some you have already seen it but I would really appreciate some help on this one. Any suggestions are most welcome.
We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
The period is always a rolling 6 months from sysdate.
This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
This is probably over complicated but we are not techie at all so are learning as we go!
We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))Hi,
It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
However, your formula is far more complicated than it needs to be.
Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
and AbsenceEnd as
LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
That's it. Not so complicated after all.
Rod West -
Case When Statement and ORA:1722 Invalid number error
Sorry I posted this in the wrong forum - I have the answer now
Cheers
HELP!!!
We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
The period is always a rolling 6 months from sysdate.
This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
This is probably over complicated but we are not Techie at all so are learning as we go! We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))
Edited by: CPearce on Sep 25, 2008 8:03 AMHi,
It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
However, your formula is far more complicated than it needs to be.
Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
and AbsenceEnd as
LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
That's it. Not so complicated after all.
Rod West -
Invalid number error when calculating with sysdate
Hello - I am getting invalid number error for query below:
SELECT *
FROM
trkg
WHERE
trkg.tran_type=500
AND
trkg.mod_date_time>sysdate-0.5
I am not sure what is wrong with above query. Strange part is that it executes fine in one environmnet and returns 'invalid number' error in other environmnet? Please help me find missing setting.more information:
Table1: LOCN_HDR with field locn_brcd and locn_id
locn_brcd locn_id
26001A 0000086
26002A 0000087
26001B 0000088
Table2: PICK_LOCN with field LOCN_ID
locn_id
0000086
0000087
0000088
Table3: TRKG with field from_locn and mod_date_time (this is timestamp field)
from_locn mod_date_Time
0000086 29-MAY-13 10.09.23.000000000 AM
0000087 29-MAY-13 10.11.48.000000000 AM
0000088 31-MAY-13 04.07.21.000000000 PM
Now I combine Table1 and Table3
select * from appwms.locn_hdr lh
join
(SELECT lh.locn_brcd,trkg.mod_Date_Time from appwms.trkg
join appwms.locn_hdr lh
on trkg.FROM_LOCN = lh.LOCN_ID
where
trkg.TRAN_TYPE = 500
and trkg.mod_Date_time>sysdate-5
) trkg1 on lh.locn_brcd=trkg1.locn_brcd
-- returns values correctly
Now when I join another table to above (ie table 2), it returns 'invalid number'
select * from appwms.locn_hdr lh
join
(SELECT lh.locn_brcd,trkg.mod_Date_Time from appwms.trkg
join appwms.locn_hdr lh
on trkg.FROM_LOCN = lh.LOCN_ID
where
trkg.TRAN_TYPE = 500
and trkg.mod_Date_time>sysdate-5
) trkg1 on lh.locn_brcd=trkg1.locn_brcd
join
(select pld.locn_id,lh.locn_brcd
from APPWMS.PICK_LOCN PLD join appwms.locn_hdr lh
on pld.locn_id = lh.LOCN_ID ) picklocn on picklocn.locn_brcd=lh.locn_brcd
why are rows returned with one join? when i have more than one join why does it return error 'invalid number'. -
Nokia E61/Speed Dial - Invalid number error
I have synchronized with my outlook to pull my contacts into the phone. I can dial out of the contacts just fine but when I try to assign one to a speed dial button I get an "invalid number" error. If I create a new contact, it works when I assign it but not when I used one pulled in from my Outlook contacts. Any ideas?
I just noticed something similar to this problem on my E65.
If I assign a number to my SpeedDial (eg. +61-3-9999-9999) it will work if I use the hard key button to invoke the speed dial.
But if I start the Speed Dial application and use that interface on the GUI to call the interface the E65 complains "Invalid Phone Number".
It is strange the the hard-key speed-dial will work, yet the application interface doesn't.
Any suggestions? -
Getting 'Invalid argument' error while uisng OPEN DATASET. Help!
Hi Experts,
I am trying to read a file from a shared server location using OPEN DATASET as shown below.
OPEN DATASET file_name FOR INPUT IN TEXT MODE ENCODING UTF-8 MESSAGE msg.
The file_name i gave is '
CNSGN-PRE-DM.COM\FUNCTIONAL\INVENTORY.CSV'.
The program compiles perfectly. But when I run the program I am getting 'Invalid argument' error. I have checked the authorization to the server, file name, file availability and everything is fine.
Strangely this code was working fine a week ago.
What could be the problem? Kindly help me!
Thanks
GopalHi Chndrasekhar,
You mean to say the we cannot use OPEN DATASET for reading file in shared server location. For example a shared folder in my PC.
Is there something wrong in the file name path I have given? It started with '//'. Do I have to start the file path wih 'file://..'?
Thanks
Gopal -
Why do I get a "DATE1 : ORA-00904 Invalid identifier" error ?
Hi,
Despite my efforts, I can't see why I get a "DATE1 : ORA-00904 Invalid identifier' error whith this request.
{code}With S1 as (
SELECT TRUNC(DATE1, 'MM'),
ROUND(SUM(VALEUR), 2)
FROM EVV_E036
GROUP BY TRUNC(DATE1, 'MM')
ORDER BY TRUNC(DATE1, 'MM'))
SELECT n,
NVL(ROUND(SUM(Valeur),2), 0)
FROM (select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n FROM dual connect by level <= 12) months
LEFT JOIN S1
ON months.n = TRUNC(DATE1, 'MM')
GROUP BY n
ORDER BY n{code}
The line in error is this one : {code}ON months.n = TRUNC(DATE1, 'MM'){code}
Any idea much appreciated !
Regards,
Christianhi,
I have done this and get no more errors. Now I see that the values I get are equal to 0. Or, I do get values different from 0 in my table ! I can't see why the left join gives 0. I have to dig this and come back tomorrow.
With S1 as (
SELECT TRUNC(DATE1, 'MM') Date1,
ROUND(SUM(VALEUR), 2) Debit
FROM EVV_E036
WHERE CLEF_VAR = (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE = 'E036')
AND DATE1 BETWEEN TO_DATE ('01/01/2007000000', 'DD/MM/YYYYHH24MISS') AND TO_DATE ('31/12/2007235959', 'DD/MM/YYYYHH24MISS')
GROUP BY TRUNC(DATE1, 'MM')
ORDER BY TRUNC(DATE1, 'MM'))
SELECT n,
NVL(ROUND(SUM(Debit),2), 0)
FROM (select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n FROM dual connect by level <= 12) months
LEFT JOIN S1
ON months.n = date1
GROUP BY n
ORDER BY n
Maybe you are looking for
-
We are in the process of consolidating all data. We have consolidated all our timekeeping/payroll data, but unfortunately the bulk of sale data still exists in tables based off store numbers. I am needing to get a list of all employees who worked o
-
Report category for this selection
u201CPeriodu201D selection dates: - Codes 1, 2, D, F, I, K u201CSelection Criteria: - Payroll Area - Person ID - Personnel Number (multiple selection) - Employment Status equal to 1 or 3 I want to have the above as part of my sel
-
Mission control freezed in yosemite
Hi, guys! Does anyone faced this problem which is the mission control will lag for sometime then for the dock does not shows out when u hover it? i have made a small video for the problem that i just mentioned....hope i can get solution from everyone
-
Why does my Ipod not show up in I tunes
My I pod touch does not show up in I tunes There is no "devices" catagory listed
-
Has anyone ever had a USB port on their Macbook Pro suddenly go dead?
I was just wondering whether anyone using a MAcbook Pro Retina has suddenly had one of their USB ports die on them? My one port does not seem to recongise any peripheral hardware I attach to the port and I am confused why this should have happened. A