Submitting multiple job on teh same table via trigger

Hi All,
I have a trigger that run multiple jobs using dbms_job on the same table. I am trying to refresh two materialized views complete via dbms_job.
Issue is when data is inserted into NET_CAB table , the trigger kicks off the bothe procedures but only the first materialized view is refreshed and not the other one.
Attached is the trigger, the procedure and materialized view
<pre>
create or replace
TRIGGER NET_CAB_TRG
AFTER INSERT OR UPDATE OR DELETE ON NET_CAB
DECLARE
pbl NUMBER;
pbl1 number;
BEGIN
SYS.DBMS_JOB.SUBMIT( JOB => pbl,what => 'P_CAB_PROC;' ) ;
SYS.DBMS_JOB.SUBMIT( JOB => pbl1,what => 'P_CABAS_PROC;') ;
END;
</pre>
<pre>
create or replace
procedure P_CAB_PROC
is
BEGIN
dbms_mview.REFRESH('P_CAB','C');
COMMIT;
END;
</pre>
<pre>
create or replace
procedure P_CABAS_PROC
is
BEGIN
dbms_mview.REFRESH('P_CABAS','C');
COMMIT;
END;
</pre>
<pre>
CREATE MATERIALIZED VIEW P_CAB
BUILD DEFERRED
USING INDEX
REFRESH COMPLETE ON DEMAND
USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS
SELECT
seq_nextval AS ID,
NAME,
SEGMENT_ID,
reproject(geometry) AS GEOMETRY
FROM NET_CAB
where sdo_geom.validate_geometry(geometry,0.005) = 'TRUE'
</pre>
<pre>
CREATE MATERIALIZED VIEW P_CABAS
BUILD DEFERRED
USING INDEX
REFRESH COMPLETE ON DEMAND
USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS
SELECT
seq_nextval AS ID,
NAME,
SEGMENT_ID,
reproject(geometry) AS GEOMETRY
FROM NET_CAB
where sdo_geom.validate_geometry(geometry,0.005) = 'TRUE'
AND cis > 4;
</pre>
Edited by: CrackerJack on May 22, 2012 8:58 PM

I can run many procedures in a job:
BEGIN
  SYS.DBMS_SCHEDULER.CREATE_JOB
       job_name        => 'JOB_REPORT_FPD'
      ,start_date      => TO_TIMESTAMP_TZ('2012/05/31 23:30:00.000000 +07:00','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
      ,repeat_interval => 'FREQ=MONTHLY;BYMONTHDAY=-1'
      ,end_date        => NULL
      ,job_class       => 'DEFAULT_JOB_CLASS'
      ,job_type        => 'PLSQL_BLOCK'
      ,job_action      => '
        DECLARE
        BEGIN
            ibox_file.fpd_nbot_report;
            ibox_file.fpd_nbot_report(''NBOT'');
            ibox_file.order_report;
            COMMIT;
        EXCEPTION
          WHEN OTHERS THEN ROLLBACK;
        END;
      ,comments        => 'USED FOR REPORTING FPD'
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'RESTARTABLE'
     ,value     => FALSE);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'LOGGING_LEVEL'
     ,value     => SYS.DBMS_SCHEDULER.LOGGING_RUNS);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'MAX_FAILURES');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'MAX_RUNS');
  BEGIN
    SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
      ( name      => 'JOB_REPORT_FPD'
       ,attribute => 'STOP_ON_WINDOW_CLOSE'
       ,value     => FALSE);
  EXCEPTION
    -- could fail if program is of type EXECUTABLE...
    WHEN OTHERS THEN
      NULL;
  END;
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'JOB_PRIORITY'
     ,value     => 3);
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'SCHEDULE_LIMIT');
  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
    ( name      => 'JOB_REPORT_FPD'
     ,attribute => 'AUTO_DROP'
     ,value     => FALSE);
  SYS.DBMS_SCHEDULER.ENABLE
    (name                  => 'JOB_REPORT_FPD');
END;
/

Similar Messages

  • Insert multiple rows into a same table from a single record

    Hi All,
    I need to insert multiple rows into a same table from a single record. Here is what I am trying to do and I need your expertise. I am using Oracle 11g
    DataFile
    1,"1001,2001,3001,4001"
    2,"1002,2002,3002,4002"
    The data needs to be loaded as
    Field1      Field2
    1               1001
    1               2001
    1               3001
    1               4001
    2               1002
    2               2002
    2               3002
    2               4002
    Thanks

    You could use SQL*Loader to load the data into a staging table with a varray column, then use a SQL insert statement to distribute it to the destination table, as demonstrated below.
    SCOTT@orcl> host type test.dat
    1,"1001,2001,3001,4001"
    2,"1002,2002,3002,4002"
    SCOTT@orcl> host type test.ctl
    load data
    infile test.dat
    into table staging
    fields terminated by ','
    ( field1
    , numbers varray enclosed by '"' and '"' (x))
    SCOTT@orcl> create table staging
      2    (field1  number,
      3     numbers sys.odcinumberlist)
      4  /
    Table created.
    SCOTT@orcl> host sqlldr scott/tiger control=test.ctl log=test.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Wed Dec 18 21:48:09 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 2
    SCOTT@orcl> column numbers format a60
    SCOTT@orcl> select * from staging
      2  /
        FIELD1 NUMBERS
             1 ODCINUMBERLIST(1001, 2001, 3001, 4001)
             2 ODCINUMBERLIST(1002, 2002, 3002, 4002)
    2 rows selected.
    SCOTT@orcl> create table destination
      2    (field1  number,
      3     field2  number)
      4  /
    Table created.
    SCOTT@orcl> insert into destination
      2  select s.field1, t.column_value
      3  from   staging s, table (s.numbers) t
      4  /
    8 rows created.
    SCOTT@orcl> select * from destination
      2  /
        FIELD1     FIELD2
             1       1001
             1       2001
             1       3001
             1       4001
             2       1002
             2       2002
             2       3002
             2       4002
    8 rows selected.

  • Can Numbers Display Multiple Views of the Same Table

    Hi,
    Excel and Appleworks both have a pull down tab on the vertical bar allowing multiple views into the same spreadsheet (table). Can Numbers do this?
    I have a set of calculations at the top of a spreadsheet that are based on years and years worth of data under the calculations (same column). I add data for each new event (the rows) and watch the calculations at the top of the data. Easy to do in Excel or Appleworks, but, I can't figure out how to do this in Numbers.
    Example:
    Spot1 Spot2
    Total 15 36
    Avg 5 12
    Jan 09 5 10
    Feb 09 6 20
    Mar 09 4 6
    Apr 09
    So... does Numbers allow the view "split" or multiple views that Excel and Appleworks allow?
    Thanks!
    Tom

    Question asked and responded several times:
    feature unavailable.
    For multiple views of a table there is an easy workaround as we may build a table whose every cells grab their contents from the 'master' one.
    _Go to "Provide Numbers Feedback" in the "Numbers" menu_, describe what you wish.
    Then, cross your fingers, and wait _at least_ for iWork'10
    Yvan KOENIG (VALLAURIS, France) mardi 1 septembre 2009 21:56:42

  • Multiple DML Processes On Same Table

    Would it be possible to do multiple DML operations on a single table, in Oracle 11.2.0.3.0 version of database sitting on Linux.
    I want to implement 2 or more parallel processes writing data into the same table at same time and the data written by each process in mutually exclusive.
    Would there be any chances of dead lock situation provided each process is independent and does not touch(read/write) data by another process?
    Thank you.

    Dear Ariean,
    Re-enforcing what Marcus, Stew, and RP have already said in their reply...
    You said...
    .... 2 or more parallel processes writing data into the same table at same time and the data written by each process in mutually exclusive ....
    Oracle ALWAYS
    Manages concurrency using ROW-Level Locks. Never automatically escalates locks to table or page level (unlike DB2 or other databases).
    Readers never block writers and writers never block readers.
    In your case, if the "writers" are mutually exclusive you'll NOT run into deadlock. In fact, deadlock is very rarely a problem in Oracle is normally due to inefficient design (ordering) of application DMLs.
    Following Oracle documentation explains data concurrency very well.. Data Concurrency and Consistency
    Hope this helps.
    vr,
    Sudhakar

  • Create multiple capture processes for same table depending on column value

    Hi,
    is it possible to create multiple realtime downstream capture processes to capture changes for the same table depending on column value?
    Prakash

    i found it - by using subset rules
    prakash

  • Allowing multiple users to see same table in object browser

    I can't seem to get multiple users to see the same table in the web based Object Browser, even though I CAN get this to work using sqlplus.
    I have been reading all of the reference documentation and have done the following:
    Created a role called edit_subjects:
    SQL>CREATE ROLE edit_subjects;
    Gave it some priviledges:
    SQL>GRANT INSERT,UPDATE,DELETE,SELECT ON myname.subjects TO edit_subjects;
    Grant the role to another guy:
    SQL>GRANT edit_subjects TO otherguy;
    In SQLPLUS I can do the following:
    C:\>sqlplus otherguy/password
    SQL> select * from myname.subjects;
    That works, BUT when I "Browse Tables" using the other guy's login in the Object Browser of the web based interface, I don't see that subjects table. (When I login as myself, I can see the subjects table) Can anyone help me?
    Thanks,
    Dan

    You might try posting this in the Express Edition forum. I'm unfamiliar with that particular front-end, so I'm not sure. Most GUI tools will have the ability to explore objects owned by other users-- there's almost always a way to pick what schema to browse-- but I have no idea how to do that in this specific tool.
    Justin

  • Multiple joins on the same table

    I'm new to SQL 2005 & C# - I'm a MySQL/PHP crossover.
    I'm using s Stored Procedure and I'm trying to do multiple joins onto
    one table.  I have 6 fields in one table that are foreign keys of
    another table:
    Table1
    id
    PrimaryCode
    SecondaryCode1
    SecondaryCode2
    SecondaryCode3
    SecondaryCode4
    SecondaryCode5
    Table 2
    id
    Title
    CommCode
    The fields in table 1 (except is obviously) hold the id of a row in
    Table 2.  When displaying data I want to display "Title" -
    "CommCode" for each item in Table 1.  I got myself started by
    searchig on the net and I have a stored procedure.  The obvious
    problem is that as it goes through the Query only the last value
    remains in place - since each value before it is cleared in the
    UNION.   How can I do this??  Here's my Stored Procedure:
    =====================================
    ALTER PROCEDURE GetRegistersSpecific
    @SearchTxt int
    AS
    SELECT
    registrations.Company,registrations.Address1,registrations.Address2,registrations.City,registrations.State,registrations.Zip,registrations.ContactName,registrations.Phone,registrations.Fax,registrations.Email,registrations.Website,registrations.Feid,registrations.BusinessType,registrations.BackupWitholding,registrations.SignedName,registrations.SignedDate,
    PrimaryCode AS MyID, Title, CommodityCode
    FROM registrations
    JOIN CommodityCodes ON PrimaryCode = CommodityCodes.id
    UNION
    SELECT
    registrations.Company,registrations.Address1,registrations.Address2,registrations.City,registrations.State,registrations.Zip,registrations.ContactName,registrations.Phone,registrations.Fax,registrations.Email,registrations.Website,registrations.Feid,registrations.BusinessType,registrations.BackupWitholding,registrations.SignedName,registrations.SignedDate,
    SecondaryCode1 AS MyID, Title, CommodityCode
    FROM registrations
    JOIN CommodityCodes ON SecondaryCode1 = CommodityCodes.id
    UNION
    SELECT
    registrations.Company,registrations.Address1,registrations.Address2,registrations.City,registrations.State,registrations.Zip,registrations.ContactName,registrations.Phone,registrations.Fax,registrations.Email,registrations.Website,registrations.Feid,registrations.BusinessType,registrations.BackupWitholding,registrations.SignedName,registrations.SignedDate,
    SecondaryCode2 AS MyID, Title, CommodityCode
    FROM registrations
    JOIN CommodityCodes ON SecondaryCode2 = CommodityCodes.id
    UNION
    SELECT
    registrations.Company,registrations.Address1,registrations.Address2,registrations.City,registrations.State,registrations.Zip,registrations.ContactName,registrations.Phone,registrations.Fax,registrations.Email,registrations.Website,registrations.Feid,registrations.BusinessType,registrations.BackupWitholding,registrations.SignedName,registrations.SignedDate,
    SecondaryCode3 AS MyID, Title, CommodityCode
    FROM registrations
    JOIN CommodityCodes ON SecondaryCode3 = CommodityCodes.id
    UNION
    SELECT
    registrations.Company,registrations.Address1,registrations.Address2,registrations.City,registrations.State,registrations.Zip,registrations.ContactName,registrations.Phone,registrations.Fax,registrations.Email,registrations.Website,registrations.Feid,registrations.BusinessType,registrations.BackupWitholding,registrations.SignedName,registrations.SignedDate,
    SecondaryCode4 AS MyID, Title, CommodityCode
    FROM registrations
    JOIN CommodityCodes ON SecondaryCode4 = CommodityCodes.id
    UNION
    SELECT
    registrations.Company,registrations.Address1,registrations.Address2,registrations.City,registrations.State,registrations.Zip,registrations.ContactName,registrations.Phone,registrations.Fax,registrations.Email,registrations.Website,registrations.Feid,registrations.BusinessType,registrations.BackupWitholding,registrations.SignedName,registrations.SignedDate,
    SecondaryCode5 AS MyID, Title, CommodityCode
    FROM registrations
    JOIN CommodityCodes ON SecondaryCode5 = CommodityCodes.id
    WHERE registrations.ID = @SearchTxt
    =====================================
    Thanks

    Well, I tried using UNION ALL and got the same response.  I also tried doing :
    Title AS SecTitle1
    Title AS SecTitle2
    Title AS SecTitle3
    etc...
    I get different values in the Output Window when I execute the query,
    but as expected it only returns the first value since the script
    executes all the way through before it outputs values.
    Here's how I'm executing:
    while (rdr.Read())
                    // get the results of each column
    string company = (string)rdr["Company"].ToString();
    string address1 = (string)rdr["Address1"].ToString();
    string address2 = (string)rdr["Address2"].ToString();
    string city = (string)rdr["City"].ToString();
    string state = (string)rdr["State"].ToString();
    string zip = (string)rdr["Zip"].ToString();
    string phone = (string)rdr["Phone"].ToString();
    string fax = (string)rdr["Fax"].ToString();
    string email = (string)rdr["Email"].ToString();
    string website = (string)rdr["Website"].ToString();
    string feid = (string)rdr["Feid"].ToString();
    string businessType = (string)rdr["BusinessType"].ToString();
    string contactName = (string)rdr["ContactName"].ToString();
    string primaryCode = (string)rdr["PrimTitle"].ToString();
    string secondaryCode1 = (string)rdr["SecTitle1"].ToString();
    string secondaryCode2 = (string)rdr["SecTitle2"].ToString();
    string secondaryCode3 = (string)rdr["SecTitle3"].ToString();
    string secondaryCode4 = (string)rdr["SecTitle4"].ToString();
    string secondaryCode5 = (string)rdr["SecTitle5"].ToString();
    string backUp = (string)rdr["BackupWitholding"].ToString();
    string signedName = (string)rdr["SignedName"].ToString();
    string signedDate = (string)rdr["SignedDate"].ToString();

  • Loading from multiple flat files to same table using SQL Loader

    Hi Gurus,
    Can anyone please brief me the pros and cons of kicking of multiple sql loader sessions that reads multiple flat files but inserting it into just one table.
    The table is not partitioned. Avg record counts for each flat file is about 5-6 million.
    Oracle 11g,
    OS: Linux
    Regards
    Cherrish Vaidiyan

    Vaidiyan wrote:
    Hi Gurus,
    Can anyone please brief me the pros and cons of kicking of multiple sql loader sessions that reads multiple flat files but inserting it into just one table.Cherrish,
    Pros -> Faster loading of more data
    Cons -> Potential performance degradation
    Test to see how much resource consuming this task would be and do a priority comparison of that multi-multi load task with other stuff that will be happening in the database in the multi-multi load time so you could decide how to share resources in that time.

  • Submitting multiple jobs from FCP

    Hi,
    I've looked in the manual and searched here but haven't found a good answer.
    I've got a project in Final Cut that has multiple sequences. What's the best way to submit all of these to Compressor for output to DVD-compatible files? Currently I have to submit one, wait until Compressor is done, do another, wait, and continue on. It's time consuming and I'd prefer to batch up all the jobs in Compressor.
    I'd hoped I could just submit a FCP project file to Compressor but that doesn't work. What format can I export quickly from FCP that I can batch submit to Compressor?
    Regards,
    fh

    When I choose File > Export > QuickTime Movie, what setting should I use? I'm not sure if the Current Settings option refers to the settings of the sequence or simply the last choice I made in the Export dialog box. Also, unlike the first method you suggested, there doesn't seem to be an option to export multiple selected sequences in one operation; I'd have to go back and do each separately.
    Current Settings is the correct setting and does indeed refer to the sequence settings (not to any previous settings used in the dialog). And remember, select DVD Studio Pro Markers - do not be misled by the other options (for Chapter Markers or Compression Markers)
    Also, if you do indeed desire to export multiple QuickTime movies:
    Select your sequences in the Browser
    From the menubar, File > Batch Export. That will open a Batch Export Queue.
    Click the Settings... button (at the bottom) to adjust/confirm your settings (in particular, specify a destination), then click Export
    Unfortunately - and this almost negates the benefit of this workflow - you do not have a provision to select markers this way. However, if your material is destined for the web - or some other delivery method where chapter markers don't matter - this method might very well speed things up.
    Lastly, and sort of a unrelated question, does using the first method - the Using Compressor option that locks up FCP - prevent distributed Compressor-ing from working? I tried sharing the task recently but it didn't work (the second computer never got any work) and I'm now wondering if that was why.
    Honestly, I don't know - haven't had the opportunity to do much distributed processing.
    Thanks for marking the posts helpful - the positive feedback is much appreciated!

  • Retriving multiple rows from the same table

    Hi all,
    I have a table consisting of an id column as well as a start and end date.
    What I want to do is select the difference between start and end time for different id's.
    For example select (endtime where id = 1 - starttime where id = 2).
    Is this possible to do using a single select statement?
    Thanks ppl

    OK, so you want every combination of dropped_id 500 with dropped_id 1000? For example:
    WITH test_data as (SELECT 500 dropped_id, TO_DATE('13/05/2009', 'DD/MM/YYYY') insert_date, TO_DATE('12/05/2009 12:00:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('12/05/2009 12:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
    SELECT 500, TO_DATE('12/05/2009', 'DD/MM/YYYY'),  TO_DATE('11/05/2009 12:04:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('11/05/2009 12:41:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
    SELECT 500,TO_DATE('11/05/2009', 'DD/MM/YYYY'), TO_DATE('10/05/2009 12:18:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('10/05/2009 12:59:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
    SELECT 1000,TO_DATE('13/05/2009', 'DD/MM/YYYY'), TO_DATE('12/05/2009 12:30:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('12/05/2009 13:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
    SELECT 1000,TO_DATE('12/05/2009', 'DD/MM/YYYY'), TO_DATE('11/05/2009 12:41:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('11/05/2009 14:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
    SELECT 1000,TO_DATE('11/05/2009', 'DD/MM/YYYY'), TO_DATE('10/05/2009 12:19:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('10/05/2009 13:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL)
    -- end test data
    SELECT tab1.insert_date insert_date1, tab2.insert_date insert_date2, tab1.dropped_id dropped_id1,   tab2.dropped_id dropped_id2, ROUND(tab2.endtime -  tab1.starttime,2) time_diff
       FROM test_data tab1
    CROSS JOIN test_data tab2
    WHERE tab1.dropped_id = 500
        AND tab2.dropped_id = 1000;
    INSERT_DA INSERT_DA DROPPED_ID1 DROPPED_ID2  TIME_DIFF
    13-MAY-09 13-MAY-09         500        1000        .06
    12-MAY-09 13-MAY-09         500        1000       1.06
    11-MAY-09 13-MAY-09         500        1000       2.05
    13-MAY-09 12-MAY-09         500        1000        -.9
    12-MAY-09 12-MAY-09         500        1000         .1
    11-MAY-09 12-MAY-09         500        1000       1.09
    13-MAY-09 11-MAY-09         500        1000      -1.94
    12-MAY-09 11-MAY-09         500        1000       -.94
    11-MAY-09 11-MAY-09         500        1000        .05
    9 rows selected.

  • Optimization of an update that uses multiple selects on the same table

    Oracle version : 10g
    Hello,
    I have created an UPDATE statement which uses two selects on a single table to do an update according to date criteria.
    Due to the fact that the update has different criteria for updating according to whether the date falls within one of two ranges
    (future or past) two selects were used together with a union between them to unite the results.
    The end result is of course two full table scans and a poorly performing execution.
    The goal is to update a field XDEL (type number) based on a date column value (column XDATE) where the dates of interest
    fall both in the past (less than sysdate minus 45 days) and in the future (greater than sysdate +90 days). For records with XDATE
    values within these ranges, I wish to set field XDEL=1
    For records in the future (>=sysdate+90):
    for a unique combination of XNAME+XCODE, where XDATE is within the date range for update, set XDEL=1
    but for a non-unique combination of XNAME+XCODE+XDATE, update XDEL=1 only for the 'oldest' future record, ie update XDEL for MIN(XDATE) only
    For records in the future (< sysdate+45):
    for a unique combination of XNAME+XCODE, where XDATE is within the date range for update, set XDEL=1
    for a non-unique combination of XNAME+XCODE, update XDEL=1 only for the 'newest' past record, ie update XDEL for MAX(XDATE) only
    The combination of XNAME+XCODE XDATE is unique. As an example of the 'in the past' scenario:
    XNAME | XCODE | XDATE
    ================
    1. AAAA ~ 002 ~ 01/01/2006
    2. AAAA ~ 002 ~ 02/01/2006
    3. AAAA ~ 002 ~ 03/01/2006
    4. XXXX ~ 123 ~ 02/01/2006
    Here, we would update XDEL in record 3. as it corresponds to MAX(XDATE) for the GROUP AAA002 (and we would also update record 4. as a unique record that meets the criteria)
    As an example of the 'in the future' scenario:
    XNAME | XCODE | XDATE
    ================
    1. HHHH ~ 002 ~ 01/01/2011
    2. HHHH ~ 002 ~ 02/01/2011
    3. HHHH ~ 002 ~ 03/01/2011
    4. XXXX ~ 123 ~ 02/01/2011
    Here, we would update XDEL in record 1. as it corresponds to MIN(XDATE) for the GROUP HHHH002 (and of course 4. as a unique record that meets the criteria)
    Here is a query that works, but is slow:
    UPDATE TAB1 SET XDEL=1 WHERE (XNAME,XCODE,XDATE) IN ((SELECT XNAME,XCODE,max(XDATE) FROM TAB1 WHERE XDATE < sysdate-45 GROUP BY XNAME,XCODE) UNION (SELECT XNAME,XCODE,min(XDATE) from TAB1 WHERE XDATE >= sysdate+90 GROUP BY XNAME,XADDR));
    XDATE is a DATE type
    XCODE and XADDR are VARCHAR2
    XDEL is number type
    Any ideas would be greatly appreciated.

    Here is a suggestion. The code is not tested.
    update tab1 t1
       set xdel = 1
    where exists (select null
                     from (
                            select xname,
                                   xcode,
                                   max(case when xdate < sysdate-45 then xdate else null end) xdate1,
                                   min(case when xdate >= sysdate+90 then xdate else null end) xdate2
                              from tab1
                             group by xname, xcode
                          ) t
                    where t1.xname = t.xname
                      and t1.xcode = t.xcode
                      and (t1.xdate = t.xdate1 or t1.xdate = t.xdate2))

  • Multiple Join over the same table

    Hi all,
    I have a question concerning joins...
    We are working with Oracle 8i.
    Consider I have the following tables t_emp_team and t_emp_names
    t_emp_team
    emp_id1, emp_id2, emp_id3
    2, 7, 9
    3, 8, 6
    4, 11, 3
    5, 10, 9
    t_emp_names
    emp_id, name
    2, Peter
    3, Mark
    4, Liz
    5, Will
    Now I want a join selecting all the names to the IDs.
    My idea was to use a join query like this:
    select
    a.emp_id1,
    a.emp_id2,
    a.emp_id3,
    b1.name,
    b2.name,
    b3.name
    from
    t_emp_team a,
    t_emp_names b1,
    t_emp_names b2,
    t_emp_names b3
    where
    a.emp_id1=b1.emp_id(+) and
    a.emp_id2=b2.emp_id(+) and
    a.emp_id3=b3.emp_id(+)
    Obviously this is not possible in Oracle as the results are not correct.
    Do you have a different idea other than Subselects for each name? (The real table has 16 IDs meaning we would end up with 16 subselects)
    Thanks for your help!
    -Peter

    Hi,
    Obviously this is not possible in Oracle as the results
    are not correct.Why do you think so ?
    SQL> select
      2  a.emp_id1,
      3  a.emp_id2,
      4  a.emp_id3,
      5  b1.name,
      6  b2.name,
      7  b3.name
      8  from
      9  t_emp_team a,
    10  t_emp_names b1,
    11  t_emp_names b2,
    12  t_emp_names b3
    13  where
    14  a.emp_id1=b1.emp_id(+) and
    15  a.emp_id2=b2.emp_id(+) and
    16  a.emp_id3=b3.emp_id(+)
    17  /
    &nbsp
       EMP_ID1    EMP_ID2    EMP_ID3 NAME       NAME       NAME
             4         11          3 Liz                   Mark
             3          8          6 Mark
             5         10          9 Will
             2          7          9 Peter
    &nbspBut it would be correct to use normzlized form
    of t_emp_team:
    SQL> desc t_emp_team_n
    Name                                      Null?    Type
    TEAM_ID                                            NUMBER
    EMP_ID                                             NUMBER
    &nbsp
    SQL> select * from t_emp_team_n;
    &nbsp
       TEAM_ID     EMP_ID
             1          4
             1         11
             1          3
             2          3
             2          8
             2          6
             3          5
             3         10
             3          9
             4          2
             4          7
             4          9
    &nbsp
    12 rows selected.
    &nbsp
    Elapsed: 00:00:00.04
    SQL> select team_id, a.emp_id, name
      2  from t_emp_team_n a, t_emp_names b
      3  where a.emp_id = b.emp_id (+)
      4  order by 1,3
      5  /
    &nbsp
       TEAM_ID     EMP_ID NAME
             1          4 Liz
             1          3 Mark
             1         11
             2          3 Mark
             2          8
             2          6
             3          5 Will
             3         10
             3          9
             4          2 Peter
             4          7
             4          9
    &nbsp
    12 rows selected.and use the advise of William Robertson:
    http://www.williamrobertson.pwp.blueyonder.co.uk/documents/one_row.html
    SQL> select team_id, substr(epath,2) "ids",
      2  rtrim(substr(npath,2),',') "members"
      3  from (
      4  select team_id, max(sys_connect_by_path(emp_id,',')) epath,
      5  max(sys_connect_by_path(name,',')) npath from (
      6  select team_id, a.emp_id, name, row_number()
      7  over(partition by team_id order by name nulls last) rn
      8  from t_emp_team_n a, t_emp_names b
      9  where a.emp_id = b.emp_id (+)
    10  )
    11  start with rn = 1 connect by prior team_id = team_id
    12  and prior rn = rn -1
    13  group by team_id
    14  )
    15  /
    &nbsp
       TEAM_ID ids                            members
             1 4,3,11                         Liz,Mark
             2 3,8,6                          Mark
             3 5,10,9                         Will
             4 2,7,9                          PeterRgds.

  • Submit Multiple Job Definitions/Job Chains with same Time window/Submit frame in mass

    Hi,
    We have a requirement to submit multiple Job Definition/Job Chains which are part of common Time Window/Submit frame/Queue....
    Ex. We have over 50+ different jobs/job chains which will runs Monday to Friday for every 2 hours on same Queue "XXX_Queue".  Instead of submitting each job/job chain manually, we would like to know if we could use any script that can achieve our requirement? since we have couple of other jobs which fall under same scenarios...
    We are on M33.104 version. Please let me know if any one has any scripts or alternate way of submitting multiple jobs/job chains in mass.
    Thanks in advance!
    Nidhi.

    Hi Nidhish,
    Here is some code to set some stuff on a job:
    //Get the partition, for global this is not necessary as global is default
    Partition part = jcsSession.getPartitionByName("GLOBAL");
    //Get the job definition
    JobDefinition jobdef=jcsSession.getJobDefinitionByName(part, "System_Info");
    //Get the submit frame
    SubmitFrame sf = jcsSession.getSubmitFrameByName(part, "SF_Every_Year");
    //Get the time window
    TimeWindow tw = jcsSession.getTimeWindowByName(part, "System_Week_WorkingHours");
    //Set the start time
    DateTimeZone dtz = new DateTimeZone(2015, 10, 18, 15, 0, 0, 0);
    //Get the Queue
    Queue SystemQ=jcsSession.getQueueByName(part, "System");
    //Create the Job
    Job infoJob=jobdef.prepare();
    //Attach queue to job
    infoJob.setQueue(SystemQ);
    //Attach submit frame, time window, start time
    infoJob.setSubmitFrame(sf);
    infoJob.setTimeWindow(tw);
    infoJob.setRequestedStartTime(dtz);
    //Print out the jobid of the job
    jcsOut.println(infoJob.getJobId());
    //Submit the job
    jcsSession.persist();
    Regards,
    HP

  • Multiple and conditions in the same table

    Ok I am going to kick myself for this, but I can't figure it out. I am trying to figure out how to find employees which match multiple criteria in the same table.
    create table emp
    (empno number,
    name  varchar2(10))
    create table skills
    (skill_id   number,
    skill_code varchar2(20))
    create table emp_skills
    (empno    number,
    skill_id number,
    rating   number)
    insert into emp values(1, 'SMITH');
    insert into emp values(2, 'JONES');
    insert into skills values (1, 'SQL');
    insert into skills values (2, 'PLSQL');
    insert into skills values (3, 'JAVA');
    insert into emp_skills values(1,1, 8);
    insert into emp_skills values(1,2, 9);
    insert into emp_skills values(1,3, 10);
    insert into emp_skills values(2,1,9);
    insert into emp_skills values(2,2,2);
    insert into emp_skills values(2,3,7);Now I need to come up with a query finding all employees who match all 3 of the following criteria:
    1) Have at least a 5 rating in SQL
    2) Have at least a 6 rating in PLSQL
    3) Have at least a 7 rating in JAVA
    So using this I would expect to return only SMITH since his/her skills meet all 3 criteria. I dont want to use OR in my query since I want all 3 to match not just one of them.
    I have a feeling I will need to self join the table - but this is going to be part of a dynamic query for APEX where the users can choose the skills and ratings they want employees to adhere to, so I dont know the number of criteria or the exact criteria in advance. But I figure if I can get a proof of concept SQL I can make it work dynamically.
    Any ideas are appreciated - sorry for the long post but I figure more detail is better

    with es1 as(
    select s.skill_code, es.empno, es.rating
    from skills s, emp_skills es
    where s.skill_id = es.skill_id
    /* main */
    select e.*
    from emp e
    where
    exists
    (select 'x' from es1
    where es1.rating >= 5
    and es1.skill_code = 'SQL'
    and es1.empno = e.empno)
    and
    exists
    (select 'x' from es1
    where es1.rating >= 6
    and es1.skill_code = 'PLSQL'
    and es1.empno = e.empno)
    and
    exists
    (select 'x' from es1
    where es1.rating >= 7
    and es1.skill_code = 'JAVA'
    and es1.empno = e.empno)
    -- Addition (Another example)
    with es1 as(
    select s.skill_code, es.empno, es.rating
    from skills s, emp_skills es
    where s.skill_id = es.skill_id
    /* main */
    select e.*
    from emp e
    where
    (select count(distinct es1.skill_code) from es1
    where
    ((es1.rating >= 5 and es1.skill_code = 'SQL')
    or
    (es1.rating >= 6 and es1.skill_code = 'PLSQL')
    or
    (es1.rating >= 7 and es1.skill_code = 'JAVA')
    and es1.empno = e.empno)
    =3;

  • Mapping to the same table through multiple references

    Hello,
    I'm trying to map aggregate fields (from my target) to mutlitple tables (back on my source), but am hung up because I need multiple references to the same table (basically a lookup values table) in my target. I believe that the problem lies in not being able to reference (in the mapping workbench at least) the same table more than once (such as through an alias, or otherwise defining multiple references) in the multi-tables tab. Is there a way around this, or some other approach to mapping it that I can take?
    Thank you,
    John

    Not exactly sure what you are trying to do, perhaps listing the object model and data model would help.
    If you are having trouble mapping the aggregate in the Mapping Workbench you may be able to workaround the problem through using a descriptor or project amendment method and defining the mapping through the code API.

Maybe you are looking for

  • How to change NLS_NUMERIC_CHARACTERS parameter for OWB SQLLDR mapping

    Hi, How to change the NLS_NUMERIC_CHARACTERS database paramater for my SQLLDR mapping? I have an input flat file which has numeric data with ',' as decimal separator means NLS_NUMERIC_CHARACTERS setting as ',.' However in my target oracle schema, the

  • Media Encoder CS6 Mac crashing on Startup

    Mac OS 10.8.2 I can open it fine in root user mode, I even copied the preferences folder over from the root user library but it still crashes. This is the report the Mac OS generated: Process:         Adobe Media Encoder CS6 [425] Path:            /A

  • Iphone 3gs will not sync with itunes copied from external hard drive.

    We transferred itunes from an external hard drive to a new laptop pc, after copying it from our old desktop.  I connected a new iphone 3gs on the laptop (first iphone on any of our computers), and itunes does not recognize the iphone, so it does not

  • Audit components for Audit Management

    Hi,  I am busy with a proto-type for Audit Management. I would like to set up an audit component called Functional location which then integrates with the Functional location structure set up in Plant Maintenance. I have configured the Audit componen

  • Resetting Data Acquisition

    I have a data acquisition vi that uses the express DAQ assistant express vi. with data in 'continuous acquistion' mode.  The data looks fine.  The user can then choose to average the data and plot it or save it.  Once the save function is completed,