V$rman_backup_job_details.END_TIME problem

We have daily incremental, every two hour archivelog and weekly dull backups scheduled for our production database. The database is registered with timezone 'Australia'
SQL> select sysdate from dual;
SYSDATE
09-AUG-2013 15:45
SQL> !date
Fri Aug  9 15:45:48 EST 2013
SQL> !env | grep TZ
TZ=Australia/NSW
SQL> !crontab -l | grep rman
0 12 * * 0 sh /projects1/oramroprod/dba_scripts/rman_fullbackup_mroprod.sh
0 12 * * 1-6 sh /projects1/oramroprod/dba_scripts/rman_incrbackup_mroprod.sh
0 00,02,04,06,08,10,14,16,18,20,22 * * * sh /projects1/oramroprod/dba_scripts/rman_archbackup_mroprod.sh
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for Solaris: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> !uname -a
SunOS ibs-ash-sr120 5.10 Generic_147441-12 i86pc i386 i86pc
SQL> !cat /etc/release
                    Oracle Solaris 10 8/11 s10x_u10wos_17b X86
  Copyright (c) 1983, 2011, Oracle and/or its affiliates. All rights reserved.
                            Assembled 23 August 2011
SQL>
I am finding a strange inconsistency on the data in v$rman_backup_job_details. The database is very small and backup duration will not exceed 30 minutes.However for INCRMENTAL LEVEL 1 and LEVEL 0 backups are showing DURATION as 10 hours!.
The RMAN backup jobs run by cron are scheduled to run at 12 GMT. Backup job starts as expected.But v$rman_backup_job_details.END_TIME is updated in 'Australia' timezone while start time is updated in GMT.
Another thing is for archivelog backups END_TIME is updated in GMT only.
Any clues ?
SQL> set lines 300
alter session set nls_date_format='DD-MON-YYYY HH24:MI';
select INPUT_TYPE,START_TIME,END_TIME,STATUS,ELAPSED_SECONDS/60/60 ELAPSED_HR from v$rman_backup_job_details where START_TIME > trunc(sysdate-7) order by START_TIME asc;SQL>
Session altered.
INPUT_TYPE    START_TIME        END_TIME          STATUS                  ELAPSED_HR
ARCHIVELOG    07-AUG-2013 16:00 07-AUG-2013 16:01 COMPLETED               .016944444
ARCHIVELOG    07-AUG-2013 18:00 07-AUG-2013 18:01 COMPLETED               .013055556
ARCHIVELOG    07-AUG-2013 18:00 07-AUG-2013 18:01 COMPLETED               .008333333
ARCHIVELOG    07-AUG-2013 20:00 07-AUG-2013 20:00 COMPLETED               .007222222
ARCHIVELOG    08-AUG-2013 02:00 08-AUG-2013 02:01 COMPLETED               .028611111
ARCHIVELOG    08-AUG-2013 08:00 08-AUG-2013 08:01 COMPLETED               .015555556
ARCHIVELOG    08-AUG-2013 10:00 08-AUG-2013 10:02 COMPLETED               .030833333
ARCHIVELOG    08-AUG-2013 10:00 08-AUG-2013 10:01 COMPLETED               .009166667
ARCHIVELOG    08-AUG-2013 12:00 08-AUG-2013 12:01 COMPLETED               .016388889
DB INCR       08-AUG-2013 12:00 08-AUG-2013 22:00 COMPLETED               10.0002778
ARCHIVELOG    08-AUG-2013 14:00 08-AUG-2013 14:01 COMPLETED               .021666667
INPUT_TYPE    START_TIME        END_TIME          STATUS                  ELAPSED_HR
ARCHIVELOG    08-AUG-2013 14:00 08-AUG-2013 14:00 COMPLETED               .006388889
ARCHIVELOG    08-AUG-2013 16:00 08-AUG-2013 16:01 COMPLETED               .022222222
ARCHIVELOG    08-AUG-2013 16:00 08-AUG-2013 16:01 COMPLETED               .017222222
ARCHIVELOG    08-AUG-2013 18:00 08-AUG-2013 18:01 COMPLETED               .014722222
ARCHIVELOG    08-AUG-2013 18:00 08-AUG-2013 18:00 COMPLETED                    .0075
ARCHIVELOG    08-AUG-2013 20:00 08-AUG-2013 20:00 COMPLETED               .005833333
ARCHIVELOG    09-AUG-2013 08:00 09-AUG-2013 08:01 COMPLETED               .018333333
ARCHIVELOG    09-AUG-2013 10:00 09-AUG-2013 10:01 COMPLETED               .023611111
ARCHIVELOG    09-AUG-2013 12:00 09-AUG-2013 12:01 COMPLETED               .018611111
ARCHIVELOG    09-AUG-2013 14:00 09-AUG-2013 14:01 COMPLETED                    .0175

oracle.dba.89 wrote:
Please show the script and that might help look into this. Also the timezone of the OS shows EST. And cron shows the scheduled time at 12hrs. It should run at 12:00 EST hours and not GMT.
Also please post output for below queries. Are backups run from the same node? (If RAC)
select value from dba_scheduler_global_attribute where attribute_name = 'DEFAULT_TIMEZONE';
Hi,
This is the backup script
#Set Variables
ORACLE_HOME=/projects1/oramroprod/oracle/product/10.2.0/db_4
ORACLE_SID=MROPROD
PATH=$PATH:$ORACLE_HOME/bin
btype="FULL"
RMAN_BACKUP_LOC=/data1/RMAN/MROPROD
export ORACLE_HOME
export ORACLE_SID
export PATH
export btype
tag="$ORACLE_SID"_"$btype"
#Print commands and their arguments as they are executed
set -x
SDATE=`date +%m%d%y`
STIME=`date +%H%M%S`
DD=`date +%d%m%y`
#Create daily backup directories
mkdir -p $RMAN_BACKUP_LOC/datafiles_backup/bkp_${DD}
mkdir -p $RMAN_BACKUP_LOC/controlfile_backup/bkp_${DD}
mkdir -p $RMAN_BACKUP_LOC/arch_backup/bkp_${DD}
mkdir $RMAN_BACKUP_LOC/logs
#Take backup
rman target / nocatalog log=$RMAN_BACKUP_LOC/logs/rman_${btype}_backup_${SDATE}_${STIME}.log << EOF1
change archivelog all crosscheck;
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
backup as compressed backupset incremental level 0 database tag '$tag' format '$RMAN_BACKUP_LOC/datafiles_backup/bkp_${DD}/%d_%s_%p';
backup as compressed backupset archivelog all not backed up 1 times FORMAT '$RMAN_BACKUP_LOC/arch_backup/bkp_${DD}/ARCH_%d_%s_%p';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO  '$RMAN_BACKUP_LOC/controlfile_backup/bkp_${DD}/%F';
delete noprompt obsolete;
delete noprompt archivelog all completed before 'sysdate-2';
EXIT;
EOF1
This is not RAC.
SQL> select value from dba_scheduler_global_attribute where attribute_name = 'DEFAULT_TIMEZONE';
VALUE
GMT

Similar Messages

  • RMAN duplicate target database from active database - performance problem

    Hello. I’m running into a major performance problem when trying to duplicate a database from a target located inside our firewall to an auxiliary located outside our firewall. Both target and auxiliary are located in the same equipment room just on different subnets. Previously I had the auxiliary located on the same subnet as the target behind the firewall and duplicating a 4.5T database took 12 hours. Now with the auxiliary moved outside the firewall attempting to duplicate the same 4.5T database is estimated to exceed 35 hours. The target is a RAC instance using ASM and so is the auxiliary. Ping, tnsping, traceroutes to and from target and auxiliary all indicate no problem or latency. Any ideas on things to consider while hunting for this elusive performance decrease?
    Thanks in advance.

    It would obviously appear network related. Have you captured any network/firewall metrics? Are all components set to full duplex? Would it be possible to take the firewall down temporarily and then test the throughput? Do you encounter any latency if you were to copy a large file across the subnets?
    You may want to check V$RMAN_BACKUP_JOB_DETAILS, V$BACKUP_SYNC_IO or V$BACKUP_ASYNC_IO when the backup is running.

  • Problem with nested select in procedure and order by

    Hi,
    I have this procedure:
    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;
    /When I call the procedure, from java, I receive this error:
    >
    Caused by: java.sql.SQLException: invalid column index
         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
    When 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, null, TROVATI, NUMERO_TROVATI);
          dbms_output.put_line('RECORD TROVATI:'||NUMERO_TROVATI);
    END; I don't receive any error messages but I don't see any message.
    Why this behaviour? I work on this procedure from the last monday. Please help me. I need to call the procedure from java.
    Thanks, bye bye.
    Edited by: Abdujaparov on Mar 5, 2009 3:44 PM

    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?
    The problem is in the dynamic query, I think:
    sql_stm:='
         SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, provider_link, log_info FROM
      (SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, provider_link, 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, provider_link, 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' ;
    OPEN recordsetCursor FOR sql_stm USING dataInizio, dataFine, idGruppo, endRow, dataInizio, dataFine, idGruppo, startRow, order_clause;Where order_clause is defined so:
    IF column_order IS NOT NULL
    THEN
    order_clause := column_order;
    ELSE
    order_clause := ' stato DESC ';
    END IF;If I insert manually a name of a column and a type of ordering (asc or desc) the ordering is executed correctly. How can I solve this issue?
    Thanks, bye bye.

  • Report SQL query problem

    Hi!
    I want to create a report with the script i copied at the bottom of this message. For some reason i get the following error:
    Error: Unable to describe SQL statement. Please correct it (WWV-13010)
    (WWV-)
    ORA-01001: invalid cursor (WWV-11230)
    ORA-00937: not a single-group group function (WWV-11230)
    Critical Error in wwerr_api_error.get_errors! SQL Error Message: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-01001: invalid cursor (WWV-)
    Does anybody have a clue where this is coming from? It seems to me that there are no diffucult un-SQL like things in the script.
    Thanks in advance!
    SELECT rse.name||', '||rse.initials||' '||rse.prefix "Medewerker"
    ,dpt.name "Afdeling"
    ,sum(round(act.duration *24,2)) "Aantal uren"
    ,count(distinct(sht.begin_date)) "Aantal dagen"
    ,count(distinct(ill.begin_time)) "Aantal keer"
    FROM ros.ros_departments@ROSPROD dpt
    ,ros.ros_scenarios@ROSPROD sco
    ,ros.ros_activity_types@ROSPROD aty
    ,ros.ros_activities@ROSPROD act
    ,ros.ros_duties@ROSPROD dty
    ,ros.ros_illnesses@ROSPROD ill
    ,ros.ros_shifts@ROSPROD sht
    ,ros.ros_resources@ROSPROD rse
    WHERE rse.id = sht.rse_id
    AND sht.name = 'Z'
    AND sht.begin_date <= sysdate
    AND ill.rse_id = rse.id
    AND trunc(sht.begin_date) BETWEEN trunc(ill.begin_time) AND trunc(nvl(ill.end_time,sysdate))
    AND dty.id = sht.dty_id
    AND decode(sign(dty.begin_time)
    ,-1, sht.begin_date + 1
    ,sht.begin_date)
    >= to_date('10-01-2000 00:00','dd-mm-yyyy hh24:mi')
    AND decode(sign(dty.begin_time)
    ,-1,sht.begin_date + 1
    ,sht.begin_date)
    <= to_date('10-01-2001 23:59','dd-mm-yyyy hh24:mi')
    AND sht.begin_date >= to_date('10-01-2000 00:00','dd-mm-yyyy hh24:mi') - 1
    AND sht.begin_date <= to_date('10-01-2001 23:59','dd-mm-yyyy hh24:mi') + 1
    AND act.dty_id = dty.id
    AND aty.id = act.ate_id
    AND aty.name = 'Ziek'
    AND sco.sce_rsr_id = sht.sce_id
    AND sco.status = 'PUBLISHED' -- <> 'TRIAL' en 'PLAN'
    AND dpt.id = sco.dpt_id
    AND dpt.name NOT IN ('BEEK/VKL', 'BEEK/VLA','EELDE/VKL','EELDE/VLA','ROTTERDAM/VKL','ROTTERDAM/VLA','SIM','STO','RCN','XSurvey')
    AND rse.name = :MDWPARAM
    AND dpt.name = :AFDPARAM
    GROUP BY rse.name||', '||rse.initials||' '||rse.prefix ,dpt.name
    ORDER BY 2,1

    Hi,
    Please run this sql statement in the SQL session. This way you will get the line number where the problem is happening.
    The error seems to be because the column in the select is not in the group by clause.
    Thanks,
    Sharmila

  • Performance problem with ojdbc14.jar

    Hi,
    We are having performance problem with ojdbc14.jar in selecting and updating (batch updates) entries in a table. The queries are taking minutes to execute. The same java code works fine with classes12.zip ans queries taking sub seconds to execute.
    We have Oracle 9.2.0.5 Database Server and I have downloaded the ojdbc14.jar from Oracle site for the same. Tried executing the java code from windows 2000, Sun Solaris and Opteron machines and having the same problem.
    Does any one know a solution to this problem? I also tried ojdbc14.jar meant for Oracle 10g, that did not help.
    Please help.
    Thanks
    Yuva

    My code is doing some thing which might be working well with classes12.zip and which does not work well with ojdbc14.jar? Any general suggestions to make the code better, especially for batch updates.
    But for selecting a row from the table, I am using index columns in the where cluase. In the code using PreparedStatement, setting all the reuired fields. Here is the code. We have a huge index with 14 fields!!. All the parameters are for where clause.
    if(longCallPStmt == null) {
    longCallPStmt = conn.prepareStatement(longCallQuery);
    log(Level.FINE, "CdrAggLoader: Loading tcdragg entry for "
    +GeneralUtility.formatDate(cdrAgg.time_hour, "MM/dd/yy HH"));
    longCallPStmt.clearParameters();
    longCallPStmt.setInt(1, cdrAgg.iintrunkgroupid);
    longCallPStmt.setInt(2, cdrAgg.iouttrunkgroupid);
    longCallPStmt.setInt(3, cdrAgg.iintrunkgroupnumber);
    longCallPStmt.setInt(4, cdrAgg.iouttrunkgroupnumber);
    longCallPStmt.setInt(5, cdrAgg.istateregionid);
    longCallPStmt.setTimestamp(6, cdrAgg.time_hour);
    longCallPStmt.setInt(7, cdrAgg.icalltreatmentcode);
    longCallPStmt.setInt(8, cdrAgg.icompletioncode);
    longCallPStmt.setInt(9, cdrAgg.bcallcompleted);
    longCallPStmt.setInt(10, cdrAgg.itodid);
    longCallPStmt.setInt(11, cdrAgg.iasktodid);
    longCallPStmt.setInt(12, cdrAgg.ibidtodid);
    longCallPStmt.setInt(13, cdrAgg.iaskzoneid);
    longCallPStmt.setInt(14, cdrAgg.ibidzoneid);
    rs = longCallPStmt.executeQuery();
    if(rs.next()) {
    cdr_agg = new CdrAgg(
    rs.getInt(1),
    rs.getInt(2),
    rs.getInt(3),
    rs.getInt(4),
    rs.getInt(5),
    rs.getTimestamp(6),
    rs.getInt(7),
    rs.getInt(8),
    rs.getInt(9),
    rs.getInt(10),
    rs.getInt(11),
    rs.getInt(12),
    rs.getInt(13),
    rs.getInt(14),
    rs.getInt(15),
    rs.getInt(16)
    }//if
    end_time = System.currentTimeMillis();
    log(Level.INFO, "CdrAggLoader: Loaded "+((cdr_agg==null)?0:1) + " "
    + GeneralUtility.formatDate(cdrAgg.time_hour, "MM/dd/yy HH")
    +" tcdragg entry in "+(end_time - start_time)+" msecs");
    } finally {
    GeneralUtility.closeResultSet(rs);
    GeneralUtility.closeStatement(pstmt);
    Why that code works well for classes12.zip (comes back in around 10 msec) and not for ojdbc14.jar (comes back in 6-7 minutes)?
    Please advise.

  • Problems with dbms_aq.listen

    I am having problem trying to listen to a set of queues.
    I have tried it with Single Consumer queues and it works fine.
    But with Multi Consumer queues dbms_aq.listen does not detect a new message enqueued and just waits until the time out then returns with the normal "No message" exception.
    Can any one tell me what I am doing wrong?
    Thanks
    Rick Laird
    code
    CREATE OR REPLACE TYPE message_type AS OBJECT (xml_message CLOB);
    exec dbms_aqadm.create_queue_table('testqueue_qtable','message_type',Null,Null,true);
    exec dbms_aqadm.create_queue('testqueue', 'testqueue_qtable');
    exec dbms_aqadm.start_queue('testqueue');
    exec dbms_aqadm.add_subscriber('testqueue',sys.aq$_agent('testqueue_subscriber',NULL,NULL));
    exec DBMS_AQADM.SCHEDULE_PROPAGATION('testqueue');
    CREATE OR REPLACE PROCEDURE MONITOR_STATUS_QUEUE(time IN NUMBER)
    IS
    pragma autonomous_transaction;
    agent_w_message sys.aq$_agent;
    agent_list dbms_aq.aq$_agent_list_t;
    wait_time INTEGER := 10;
    no_message EXCEPTION;
    pragma EXCEPTION_INIT(no_message, -25254);
    new_status VARCHAR2(30);
    monitor BOOLEAN := TRUE;
    begin_time number;
    end_time number;
    v_dequeue_options dbms_aq.dequeue_options_t;
    v_message_properties dbms_aq.message_properties_t;
    v_message_type message_type;
    v_dequeue_msg_id RAW(40);
    v_xml_message CLOB;
    v_message_text varchar2(2000);
    v_amount number;
    BEGIN
    begin_time := dbms_utility.get_time;
    WHILE (monitor)
    LOOP
    BEGIN
    -- agent_list(1) := sys.aq$_agent('testqueue_agent', 'testqueue', NULL);
    agent_list(1) := sys.aq$_agent('agent1', 'testqueue', NULL);
    /* wait for order status messages */
    dbms_aq.listen(agent_list, 0, agent_w_message);
    dbms_output.put_line('Agent' || agent_w_message.name || ' Address '|| agent_w_message.address);
    /* dequeue the message from the queue */
    v_dequeue_options.consumer_name := 'testqueue_subscriber';
    v_dequeue_options.wait := 0.5;
    -- v_dequeue_options.wait := dbms_aq.NO_WAIT;
    dbms_aq.dequeue('testqueue',v_dequeue_options, v_message_properties,
    v_message_type,v_dequeue_msg_id);
    v_amount := dbms_lob.getlength(v_message_type.xml_message);
    dbms_lob.read(v_message_type.xml_message,v_amount,1,v_message_text);
    dbms_output.put_line('New Message :'||v_message_text);
    /* exit if we have been working long enough */
    end_time := dbms_utility.get_time;
    IF (end_time - begin_time > time) THEN
    EXIT;
    END IF;
    EXCEPTION
    WHEN no_message THEN
    dbms_output.put_line('No messages so far');
    end_time := dbms_utility.get_time;
    --exit if we have done enough work
    IF (end_time - begin_time > time) THEN
    EXIT;
    END IF;
    END;
    END LOOP;
    commit;
    END;
    create or replace procedure enqueue is
    v_enqueue_options dbms_aq.enqueue_options_t;
    v_messages_properties dbms_aq.message_properties_t;
    v_message_type message_type;
    v_message_locator CLOB;
    v_enqueue_msg_id RAW(40);
    v_select_sql varchar2(2000);
    v_xml_message varchar2(2000);
    v_temp_clob CLOB;
    begin
    v_xml_message := '<TESTING><TEST>'||to_char(sysdate,'HH:MI:SS')||'</TEST></TESTING>';
    dbms_lob.createtemporary(v_temp_clob,true);
    dbms_lob.write(v_temp_clob,length(v_xml_message),1,v_xml_message);
    v_message_type := message_type(empty_clob());
    dbms_aq.enqueue(
    queue_name => 'testqueue',
    enqueue_options => v_enqueue_options,
    message_properties => v_messages_properties,
    payload => v_message_type,
    msgid => v_enqueue_msg_id);
    v_select_sql := ' select t.user_data.xml_message from testqueue_qtable t where t.msgid = :MSG_ID';
    execute immediate v_select_sql INTO v_message_locator using v_enqueue_msg_id;
    dbms_lob.copy( dest_lob => v_message_locator,
    src_lob => v_temp_clob,
    amount => dbms_lob.getlength(v_temp_clob));
    COMMIT;
    end enqueue;

    Hi,
    Your subscriber is called testqueue_subscriber. You must use the same consumer name in the agent list for dbms_aq.listen
    Change
    agent_list(1) := sys.aq$_agent('agent1', 'testqueue', NULL);
    to
    agent_list(1) := sys.aq$_agent('testqueue_subscriber', 'testqueue', NULL);

  • Problem while bringing Google Calendar events to Oracle Tables

    Hi Friends,
    I have written the following code to bring the Google Calendar Events to Oracle Tables...
    CREATE OR REPLACE procedure XX_DEV.authenticate_service_test(p_email in varchar2,p_password in varchar2)
    is
    l_request utl_http.req;
    l_response utl_http.resp;
    l_params varchar2(255);
    l_resp_data VARCHAR2(4000);-- CHARACTER SET;
    l_auth_token VARCHAR2(4000);
    l_cal_entry CLOB;
    v_response_xml XMLType;
    v_entry_id varchar2(100);
    xml_result xmltype;
    cnt number:= 0;
    v_xmldoc CLOB;
    v_start_time date;
    v_end_time date;
    cursor c1 is select x.title title, x.content content, x.where where, x.start_time start_time, x.end_time end_time, x.entry_id entry_id from
    xmltable('feed/entry'
    passing xmltype(v_xmldoc)
    columns title varchar2(1000) path '/entry/title/text()'
    ,content clob path '/entry/content/text()'
    ,where clob path '/entry/gd-where/@valueString'
    ,start_time varchar2(100) path '/entry/gd-when/@startTime'
    ,end_time varchar2(100) path '/entry/gd-when/@endTime'
    ,entry_id varchar2(1000) path '/entry/id'
    ) x ;
    begin
    -- access the oracle wallet to allow us to make an https request
    utl_http.set_wallet(path => 'file:/u01/app/oracle/product/11.2.0/owm/wallets/oracle11/',password => 'srisys123');
    -- set up the request body with our credentials
    l_params := 'Email=' || p_email || '&Passwd=' || p_password ||'&service=cl' || '&source=e-DBA-test-1.0';
    l_request := utl_http.begin_request('https://www.google.com/accounts/ClientLogin','POST','HTTP/1.1');--accounts/ClientLogin
    -- set the request headers
    utl_http.set_header(l_request,'Content-Type','application/x-www-form-urlencoded');
    utl_http.set_header(l_request,'Content-Length',length(l_params));
    -- write out the request body
    utl_http.write_text( l_request, l_params );
    -- get the response
    l_response := utl_http.get_response( r => l_request );
    dbms_output.put_line('Status Code: '||l_response.status_code);
    loop
    utl_http.read_line( r => l_response, data => l_resp_data, remove_crlf => TRUE);
    dbms_output.put_line(l_resp_data);
    if substr(l_resp_data, 1, 5) = 'Auth=' then
    l_auth_token := substr(l_resp_data, 6);
    end if;
    end loop;
    exception
    when utl_http.end_of_body then
    null;
    dbms_output.put_line('Auth Token: '||l_auth_token);
    utl_http.end_response ( l_response );
    -- replace the substitution variables in the template with the parameter values
    --utl_http.end_response ( l_response );
    l_request := utl_http.begin_request(
    'http://www.google.com/calendar/feeds/default/private/full',
    'GET',
    'HTTP/1.1');
    utl_http.set_header(
    l_request,
    'Content-Type',
    'application/atom+xml');
    utl_http.set_header(
    l_request,
    'Authorization',
    'GoogleLogin auth='||l_auth_token);
    l_response := utl_http.get_response( r => l_request );
    utl_http.read_text(
    l_response,
    l_cal_entry
    dbms_output.put_line('Status Code: ' || l_response.status_code);
    /*select replace(l_cal_entry,'<?xml version='||'''1.0'''||' encoding='||'''UTF-8'''||'?>','') into l_cal_entry from dual;
    select ltrim(l_cal_entry,substr(l_cal_entry,1,148)) into l_cal_entry from dual;
    select '<feed'||l_cal_entry into l_cal_entry from dual;
    select replace (l_cal_entry,':','-') into l_cal_entry from dual;*/
    dbms_output.put_line('Calendar Event: ' || l_cal_entry);
    -- xml_result :=XMLType.extract(l_cal_entry,'//title');
    delete from xml_test1;
    insert into xml_test1 values (l_cal_entry);
    utl_http.end_response ( l_response );
    select DATA into v_xmldoc from XML_TEST1;
    execute immediate 'alter session set events = ''31156 trace name context forever, level 2''';
    for i in c1
    loop
    l_cal_entry:= NULL;
    dbms_output.put_line('Result: '||i.title||'*'||i.content||'*'||i.name||'*'||i.start_time||'*'||i.end_time||'*'||i.entry_id);
    begin
    select 1 into cnt from events_bkp where entry_id = i.entry_id;
    select nvl(to_date(rtrim(replace(i.start_time,'T',' '),substr(replace(i.start_time,'T',' '),12,20))||
    replace(substr(replace(i.start_time,'T',' '),12,8),'-',':'),'yyyy-mm-dd hh24:mi:ss'),sysdate) into v_start_time from dual;
    select nvl(to_date(rtrim(replace(i.end_time,'T',' '),substr(replace(i.end_time,'T',' '),12,20))||
    replace(substr(replace(i.end_time,'T',' '),12,8),'-',':'),'yyyy-mm-dd hh24:mi:ss'),sysdate) into v_end_time from dual;
    update events_bkp set description = i.title, notes = nvl(i.content,'No Notes'), start_date_time = v_start_time, end_date_time = v_end_time
    where entry_id = i.entry_id;
    exception when others then
    select nvl(to_date(rtrim(replace(i.start_time,'T',' '),substr(replace(i.start_time,'T',' '),12,20))||
    replace(substr(replace(i.start_time,'T',' '),12,8),'-',':'),'yyyy-mm-dd hh24:mi:ss'),sysdate) into v_start_time from dual;
    select nvl(to_date(rtrim(replace(i.end_time,'T',' '),substr(replace(i.end_time,'T',' '),12,20))||
    replace(substr(replace(i.end_time,'T',' '),12,8),'-',':'),'yyyy-mm-dd hh24:mi:ss'),sysdate) into v_end_time from dual;
    insert into events_bkp values(events_seq.nextval, 9, 1,1, 4, i.title, nvl(i.content,'No Notes'), v_start_time, v_end_time,'','',
    4, 1, sysdate, 1, sysdate, 13, i.entry_id);
    end;
    commit;
    end loop;
    execute immediate 'alter session set events = ''31156 trace name context off''';
    end authenticate_service_test;
    I am able to execute it successfully with my username and password but I am getting error when the number of events are more than 15...
    The parameter l_cal_entry which is of clob datatype is not holding the whole xml data.
    Please advice....
    Thank You,
    Srikanth

    Hi Friends,
    Now I am able to load all the events of a user by adding the following code
    loop
    utl_http.read_text(l_response, l_cal);
    l_cal_entry:= l_cal_entry||l_cal;
    end loop;
    but I am getting problem when the user has more than one calendar. The Begin_request link I am using is...
    'https://www.google.com/calendar/feeds/default/private/full'
    Using this, I am able to get only the events of a default calendar associated to the user.
    How can I get the events of all calendars or a particular calendar associated with the user.
    I may have to change the above link... I have tried with various combinations by appending calendar id but I am unable get the right combination
    Please advice...
    Thank You,
    Srikanth

  • Bulk Collect Limiting data problem

    Hi all,
    i am using a cursor for migrating data form one table to another.
    i say:
    fetch c_mycur bulk collect into r_myrow limit 10000;
    exit when c_mycur%notfound;
    forall i in r_myrow.first .. r_myrow.last
    insert into table2 values r_myrow(i);
    But there is a missout point that:
    Table1 has 400234 data but it copies 400000 to the table2.
    I want it to do full copy.How can i correct this???
    Thanks...

    Dear all..
    Sory i just want to share about bulk collect limiting problem, because i also get the same problem when using it. Actually before I just want to check the performance between bulk collect with explicit cursor and implicit cursor. below is my testing :
    SQL> ed
    Wrote file afiedt.buf
    1 DECLARE
    2 CURSOR c_server IS
    3 SELECT * FROM TRAN_DATA;
    4 TYPE transerver IS TABLE OF c_server%ROWTYPE;
    5 cur_server transerver;
    6 TYPE mytran IS TABLE OF TRAN_DATA%ROWTYPE;
    7 c_tran mytran;
    8 START_TIME NUMBER;
    9 END_TIME NUMBER;
    10 L_count NUMBER;
    11 BEGIN
    12 EXECUTE IMMEDIATE 'TRUNCATE TABLE TRAN_DATA_SERVERS';
    13 START_TIME := DBMS_UTILITY.GET_tIME;
    14 OPEN c_server;
    15 LOOP
    16 FETCH c_server BULK COLLECT INTO cur_server LIMIT 100;
    [b] 17 EXIT WHEN c_server%NOTFOUND;
    18 FORALL i IN cur_server.FIRST..cur_server.LAST
    19 INSERT INTO tran_data_servers VALUES cur_Server(i);
    20 END LOOP;
    21 CLOSE c_server;
    22 SELECT count(*) INTO l_count FROM tran_data_servers;
    23 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    24 END_TIME := DBMS_UTILITY.GET_tIME;
    25 DBMS_OUTPUT.PUT_LINE('TIME FOR CURSOR BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    26 EXECUTE IMMEDIATE 'TRUNCATE TABLE array_TRAN_DATA';
    27 START_TIME := DBMS_UTILITY.GET_tIME;
    28 SELECT * BULK COLLECT INTO c_tran FROM TRAN_DATA;
    29 FORALL i IN c_tran.FIRST..c_tran.LAST
    30 INSERT INTO array_tran_data VALUES c_tran(i);
    31 END_TIME := DBMS_UTILITY.GET_tIME;
    32 L_count:= null;
    33 SELECT count(*) INTO l_count FROM array_tran_data;
    34 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    35 DBMS_OUTPUT.PUT_LINE('select into BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    36* END;
    37 /
    row processing = 287400
    TIME FOR CURSOR BULK FOR ALL = 789
    row processing = 287417
    select into BULK FOR ALL = 811
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
    1 DECLARE
    2 CURSOR c_server IS
    3 SELECT * FROM TRAN_DATA;
    4 TYPE transerver IS TABLE OF c_server%ROWTYPE;
    5 cur_server transerver;
    6 TYPE mytran IS TABLE OF TRAN_DATA%ROWTYPE;
    7 c_tran mytran;
    8 START_TIME NUMBER;
    9 END_TIME NUMBER;
    10 L_count NUMBER;
    11 BEGIN
    12 EXECUTE IMMEDIATE 'TRUNCATE TABLE TRAN_DATA_SERVERS';
    13 START_TIME := DBMS_UTILITY.GET_tIME;
    14 OPEN c_server;
    15 LOOP
    16 FETCH c_server BULK COLLECT INTO cur_server LIMIT 100;
    17 FORALL i IN cur_server.FIRST..cur_server.LAST
    18 INSERT INTO tran_data_servers VALUES cur_Server(i);
    [b]19 EXIT WHEN c_server%NOTFOUND;
    20 END LOOP;
    21 CLOSE c_server;
    22 SELECT count(*) INTO l_count FROM tran_data_servers;
    23 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    24 END_TIME := DBMS_UTILITY.GET_tIME;
    25 DBMS_OUTPUT.PUT_LINE('TIME FOR CURSOR BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    26 EXECUTE IMMEDIATE 'TRUNCATE TABLE array_TRAN_DATA';
    27 START_TIME := DBMS_UTILITY.GET_tIME;
    28 SELECT * BULK COLLECT INTO c_tran FROM TRAN_DATA;
    29 FORALL i IN c_tran.FIRST..c_tran.LAST
    30 INSERT INTO array_tran_data VALUES c_tran(i);
    31 END_TIME := DBMS_UTILITY.GET_tIME;
    32 L_count:= null;
    33 SELECT count(*) INTO l_count FROM array_tran_data;
    34 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    35 DBMS_OUTPUT.PUT_LINE('select into BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    36* END;
    SQL> /
    row processing = 287417
    TIME FOR CURSOR BULK FOR ALL = 558
    row processing = 287417
    select into BULK FOR ALL = 624
    PL/SQL procedure successfully completed.
    As you can see if we put the EXIT WHEN c_server%NOTFOUND; before the forall statement then not all the row will processing, but if we put EXIT WHEN c_server%NOTFOUND; after the forall statement it's will processing all rows. So maybe the solutions just put the EXIT WHEN c_server%NOTFOUND; after the forall statement. As you can see also there's the different bulk collect with implicit and explicit cursor, i think using explicit with limit will be more faster.
    Thank you
    Thanks

  • 10g Dev Preview -- sub query problem

    I'm not sure if this is the place to report bugs or problems with the 10g developer preview. But here goes.
    I have some code that used to work. The idea is to find "task" objects that are not assigned to anyone, ie, have no "task assignment" records pointing to them. This code used to work. It creates an expression that when queried returns all Task objects that are not in the subQuery which fetches task assignments.
    ExpressionBuilder eb = new ExpressionBuilder();
    ReportQuery queryAssigned = new ReportQuery(TaskAssignment.class, new ExpressionBuilder());
    ReportQuery queryAssigned = new ReportQuery(TaskAssignment.class, new ExpressionBuilder());
    queryAssigned.addAttribute("ID", eb.get("task").get("ID"))
    return eb.get("ID").notIn(eb.subQuery(queryAssigned));
    When I use TOPLink 10g, however, I get the following error:
    [junit] Query: ReadAllQuery(com.marketsoft.workflow.Task)
    [junit] Local Exception Stack:
    [junit] Exception [TOPLINK-6015] (Oracle TopLink - 10g Developer Preview 3 (10.1.3.0 ) (Build 041116)): oracle.toplink.ex
    ceptions.QueryException
    [junit] Exception Description: Invalid query key [task] in expression.
    [junit] Query: ReadAllQuery(com.marketsoft.workflow.Task)
    [junit] at oracle.toplink.exceptions.QueryException.invalidQueryKeyInExpression(QueryException.java:491)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.validateNode(QueryKeyExpression.java:555)
    [junit] at oracle.toplink.expressions.Expression.normalize(Expression.java:2587)
    [junit] at oracle.toplink.internal.expressions.DataExpression.normalize(DataExpression.java:349)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:369)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:356)
    [junit] at oracle.toplink.internal.expressions.DataExpression.normalize(DataExpression.java:343)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:369)
    [junit] at oracle.toplink.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:356)
    [junit] at oracle.toplink.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:951)
    [junit] at oracle.toplink.internal.expressions.SubSelectExpression.normalizeSubSelect(SubSelectExpression.java:123)
    [junit] at oracle.toplink.internal.expressions.ExpressionNormalizer.normalizeSubSelects(ExpressionNormalizer.java:82)
    [junit] at oracle.toplink.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:982)
    [junit] at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQuery
    Mechanism.java:223)
    [junit] at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.prepareCursorSelectAllRows(ExpressionQuery
    Mechanism.java:587)
    [junit] at oracle.toplink.queryframework.CursorPolicy.prepare(CursorPolicy.java:137)
    [junit] at oracle.toplink.queryframework.CursoredStreamPolicy.prepare(CursoredStreamPolicy.java:93)
    [junit] at oracle.toplink.queryframework.ReadAllQuery.prepare(ReadAllQuery.java:571)
    [junit] at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:367)
    [junit] at oracle.toplink.queryframework.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:506)
    [junit] at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:537)
    [junit] at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:408)
    [junit] at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1977)
    [junit] at oracle.toplink.publicinterface.Session.executeQuery(Session.java:973)
    This maybe isn't that surprising. I see that the unbound ExpressionBuilders might be causing problems. However, which I switch to something a little bit more like what I see in the examples:
    ExpressionBuilder eb = new ExpressionBuilder();
    ExpressionBuilder assignBuilder = new ExpressionBuilder();
    ReportQuery queryAssigned = new ReportQuery(TaskAssignment.class, assignBuilder);
    queryAssigned.addAttribute("ID", assignBuilder.get("task").get("ID"));
    queryAssigned.useDistinct();
    return eb.get("ID").notIn(eb.subQuery(queryAssigned));
    In this case, it seems to generate messed up SQL where the table name goes missing:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Developer Preview 3 (10.1.3.0 ) (Build 041116)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00903: invalid table name
    Error Code: 903
    Call:SELECT COUNT(*) FROM TASKS t0 WHERE ((t0.ID NOT IN (SELECT DISTINCT t1.ID FROM )) AND (t0.ITEMTYPE = ?))
         bind => [Task]
    Query:ReportQuery(com.marketsoft.workflow.Task)
    Local Exception Stack:

    Charles,
    I couldn't reproduce your problem. I used an employee example in which Employee has 1:m relationship with PhoneNumber. My code and sql are as follows:
         ReadAllQuery query = new ReadAllQuery(Employee.class);
         ExpressionBuilder emp = new ExpressionBuilder(Employee.class);
         ExpressionBuilder phone = new ExpressionBuilder();
         ReportQuery subquery = new ReportQuery(PhoneNumber.class, phone);
         subquery.addAttribute("id", phone.get("owner").get("id"));
         subquery.useDistinct();
         Expression expression = emp.get("id").notIn(subquery);
         query.setSelectionCriteria(expression);
    Vector employees = (Vector)getSession().executeQuery(query);
    SELECT t0.VERSION, t1.EMP_ID, t0.L_NAME, t0.F_NAME, t1.SALARY, t0.EMP_ID, t0.GENDER, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.START_TIME, t0.END_TIME, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE ((t0.EMP_ID NOT IN (SELECT DISTINCT t2.EMP_ID FROM PHONE t4, SALARY t3, EMPLOYEE t2 WHERE ((t2.EMP_ID = t4.EMP_ID) AND (t3.EMP_ID = t2.EMP_ID)))) AND (t1.EMP_ID = t0.EMP_ID))
    Shanno

  • Pls help me our for date problem.

    There are two tables a header and a detail
    In the details is having start_time and end_time
    I put a format mask that I want to show only hh24: mi.
    The problem is if, I changed the hh24: mi values the date bounds back to the first day of the current month. Why it's so?
    I used another field st,et(start_time & end_time) these are non-database items of number type and here also I put the format mask hh24: mi. So the data goes in the database in the form of seconds.
    I want in start_time and end time (sysdate +the hh24: mi value I given)
    How to do this??????.Any idea .Pls help me out ....
    [email protected]

    machan nuwan,
    there are two way
    client side genaration(flex)
    server side genaration(java,php,crystal report...)
    client side
    My openion is before u print.
    create pdf in your server and save (then client can access it by usinf URL)
    keep the saved location(URL) in DB and then
    pass the URL to client (when you are doing reporting this process is happenning machan)
    see this link for more(me link1 balapan tawa.mage 1k newei)hope this will help u. http://amthekkel.blogspot.com/2010/09/flex-web-app-generating-pdf-reports.html
    otherwise u can genarate reports using crystal report or what ever tool and put into server then pass the URL to client then client can access the pdf and print it.
    hope this will help you machan.thnx

  • Problems creating a view that's a union of two other views

    Hello all you Oracle folks,
    I'm pretty new to this Oracle thing, coming over from SQL Server where life was simple. Here's my issue;
    I am trying to create a view that is a union of two other views.
    I can run the top SELECT of this view (before the UNION) and it works no problem, and I can run the bottom SELECT (after the UNION) and it also works with no problem. I can run a DESC on both views involved, and those also work without any problem.
    When I try to run the SQL all together though, I get this;
    SQL> CREATE materialized view trkmaster.cmp_pmr_union refresh force ON demand AS SELECT 'CMR'
    2 "Ticket_System", "Id_col" "Ticket", "Submitter", "Submit_Date", "Submit_To",
    3 "Actual_Activity_Start_Date" "Start_Date", "Actual_Activity_Start_Time" "Start_Time",
    4 "Actual_Activity_End_Date" "End_Date", "Actual_Activity_End_Time" "End_Time",
    5 "Close_Date", "Risk_Level" "Level", "Activity_Type" "Type", "Activity_Category"
    6 "Category", "Hardware_Name" "Hardware", "Platform", "Application_Name" "Application",
    7 "Completion_Status" "Status", "Area_CMPO" "Owner", "Outage_Minutes" "Total_Outage_Mins",
    8 "Acorde_Downtime__in_minutes_" "Acorde", "Atlas", "Corporate_Email_Downtime"
    9 "Corporate_Email", "Data_Warehouse_Downtime__In_M6" "Data_Warehouse",
    10 "E__Commerce_Downtime__In_Mins_" "ECommerce", "FMDS__FIVR_" "FMDS_FIVR",
    11 "FMDS_Hotels_Downtime" "FMDS_Hotels", "FMDS_Internet_Downtime" "FMDS_Internet",
    12 "FMDS_Resv__Ctr_Downtime" "FMDS_Resv_Ctr", "GDS_Downtime__In_Mins_" "GDS",
    13 "HI_Online_Downtime__In_Mins_" "HI_Online", "Holidex__CRO____In_Mins_" "Holidex_CRO",
    14 "Holidex__Hotels____In_Mins_" "Holidex_Hotels", "Hyperion_Essbase",
    15 "IHGMail_Downtime__In_Mins_" "IHG_Mail", "Kofax_Downtime__in_minutes_" "Kofax",
    16 "PeopleSoft_Fin_Downtime_In_Mi1" "Peoplesoft", "PERFORM__HIRO____In_Mins_" "Perform_HIRO"
    17 FROM CMP.CHRQVCHANGE_MANAGEMENT_REQUEST UNION SELECT 'PMR' "Ticket_System", "Id_col"
    18 "Ticket", "Submitter", "Submit_Date", "Submit_To", "Problem_Start_Date" "Start_Date",
    19 "Problem_Start_Time" "Start_Time", "Problem_End_Date" "End_Date", "Problem_End_Time"
    20 "End_Time", "Close_Date", "Severity_Level" "Level", "Problem_Type" "Type",
    21 "Occurrence_Type" "Category", "Hardware_Name" "Hardware", "Platform", "Application_Name"
    22 "Application", "Close_Code" "Status", "Problem_Owner" "Owner",
    23 "TOTAL_Outage_Time__If_Any_" "Total_Outage_Time", "Acorde_Downtime__in_minutes_" "Acorde",
    24 "Atlas", "Corporate_Email_Downtime" "Corporate_Email", "Data_Warehouse_Downtime__In_M6"
    25 "Data_Warehouse", "E__Commerce_Outage_Time__Mins_" "ECommerce", "FMDS__FIVR_" "FMDS_FIVR",
    26 "FMDS_Hotels_Outage_Time__In_M5" "FMDS_Hotels", "FMDS_Internet_Outage_Time__Mi4"
    27 "FMDS_Internet", "FMDS_Resv__Ctr_Outage_Time__M3" "FMDS_Resv_Ctr",
    28 "GDS_Outage_Time__Mins_" "GDS", "HI_Online_Outage_Time__In_Min2" "HI_Online",
    29 "Holidex__CRO____In_Mins_" "Holidex_CRO", "Holidex__Hotels____In_Mins_" "Holidex_Hotels",
    30 "Hyperion_Essbase", "IHG_Mail_Outage_Time__In_Mins_" "IHG_Mail",
    31 "Kofax_Downtime__in_minutes_" "Kofax", "PeopleSoft_Fin_Downtime_In_Mi1" "Peoplesoft",
    32 "PERFORM__HIRO____In_Mins_" "Perform_HIRO" FROM PMR.CHRQVPROBLEM_MANAGEMENT;
    "PERFORM__HIRO____In_Mins_" "Perform_HIRO" FROM PMR.CHRQVPROBLEM_MANAGEMENT
    ERROR at line 32:
    ORA-00942: table or view does not exist
    The 'CMR' and 'PMR' as Ticket_System is me trying to assign a literal as a newly created column.
    All the data types match from one view to the other.
    If I switch around the SQL so the 'CMR' view is at the bottom and the 'PMR' view is at the top, it still errors out on the 'PMR' view as not existing, even though I can DESC it and run the SELECT using that view. A coworker thinks it could be some kind of view alias issue (?).
    I know the view exists, and I can access it no problem. Any ideas why this isn't working? It seems so simple, I could do this in a heartbeat in SQL Server. I have very few hairs left to rip out, so any help would be appreciated.

    SELECT 'CMR' "Ticket_System",
    "Id_col" "Ticket",
    ....you have wrapped up your columns with a double quotes and use an alias. i tried the same thing
    but using a different table and it does not work.
    SQL> desc emp;
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                    NOT NULL NUMBER(2)
    SQL> select "empno" "employee_number"
      2    from emp;
    select "empno" "employee_number"
    ERROR at line 1:
    ORA-00904: "empno": invalid identifier
    SQL> how were you able to run the top level of your SQL before the UNION clause? did you run it thru some tools
    other than SQL*Plus?

  • V$RMAN_BACKUP_JOB_DETAILS view showing rman status running

    Hi,
    There is no rman session running in the database but still V$RMAN_BACKUP_JOB_DETAILS shows status as running
    select SID,username, opname,to_char(START_TIME,'dd mm yyyy hh:mm:ss'),TOTALWORK, sofar, (sofar/totalwork) * 100 done,TIME_REMAINING/3600/24,
    to_char(sysdate + TIME_REMAINING/3600/24,'dd mm yyyy hh:mm:ss') end_at
    from v$session_longops
    where totalwork > sofar
    AND opname NOT LIKE '%aggregate%'
    AND opname like 'RMAN%'SQL>   2    3    4    5    6
      7  ;
    no rows selected
    SQL> select sid, CLIENT_INFO ch, seq#, event, state from v$session where program like '%rman%';
    no rows selected
    SQL> select SESSION_KEY,SESSION_RECID,START_TIME,END_TIME,STATUS from V$RMAN_BACKUP_JOB_DETAILS where START_TIME > sysdate-3;
    SESSION_KEY SESSION_RECID START_TIM END_TIME  STATUS
           2853          2853 20-NOV-12 20-NOV-12 COMPLETED
           2862          2862 22-NOV-12           RUNNING
           2864          2864 22-NOV-12 22-NOV-12 COMPLETEDplease can anyone shed some light on it
    Thanks

    Fixed.
    In my solution I grabbed the command id from the details view and then matched that with the sid in the status view
    SQL> select session_key, command_id, status, time_taken_display from v$rman_backup_job_details where command_id='2012-11-27T22:30:37';
    SESSION_KEY COMMAND_ID                        STATUS
    TIME_TAKEN_DISPLAY
            602 2012-11-27T22:30:37               RUNNING WITH ERRORS
    16:32:53
    SQL> select sid from v$rman_status where COMMAND_ID='2012-11-27T22:30:37';
           SID
             4
             4
    SQL>then I made sure I was sys, before grabbing the session info and killing the session
    SQL> select user from user_users;
    USER
    SYS
    SQL>
    SQL> select sid,serial#,inst_id from gv$session  where sid=4 and serial#=3;
           SID    SERIAL#    INST_ID
             4          3          2
    SQL> alter system kill session '4,3,@2' immediate;
    System altered.
    SQL> let me know if this worked for you.
    hope this helps, C

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    Kobi
    See Code example below:
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              super(true);
              this.parent = parent;
              try
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
                   System.out.println(e.getMessage());
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
              t.start();
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
              try
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
                   player.setLoopCount(-1);
                   player.prefetch();
                   player.start();
              catch(Exception e)
                   System.out.println(e.getMessage());
         public void run()
              Graphics g = getGraphics();
              play();
              while (true)
                   tick();
                   input();
                   render(g);
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   imgBackgoundX++;
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   imgBackgoundX--;
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
              this.flushGraphics();
    }

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

Maybe you are looking for