Should I use a sequence?

Hi,
I would like to achieve the following
h5. table A
record #1
--column 1 (number): 1 (pk)
--column 2 (char): AAR
record #2
--column 1 (number): 2 (pk)
--column 2 (char): GGT
h5. table B
column 1 (number): 1 (pk)
column 2 (number): 1 (fk on table A)
column 3 (char): AAR-1
The idea is that column 3 on table B is automatically generated by the application., and gets the value according to the FK to table A
Therefore, the next record created in table B, if having column 2 value as "1" (from table A) then column 3 should get value "AAR-2"
Instead if in table B a record is inserted pointing to column 2 values "2", then column 3 would get GGT-01.
What do you recommend? To have an additional column (number) in table A starting with 0, and every time a new record is inserted in table B I should get the max(id) and increment by 1 after creating the record. Or would it be reasonable to create a sequence for each record table A (assuming that a table will never grow to more than 500 records)?
Thanks for your help

In the below example, I am not using sequence; I used trigger which works for PK/FK and sequence simultaneously : Windows XP and Enterprise Edition 11.2.0.1
create table tablea(car_code number,car_name varchar2(50));
insert into tablea values (1,'Audi');
insert into tablea values (2,'Mercedes');
insert into tablea values (3,'Honda');
insert into tablea values (4,'Toyota');
insert into tablea values (5,'Maruti');
create table tableb(person_name varchar2(40),his_car_id number,his_car_name varchar2(60));
create or replace trigger trigb
before insert on tableb
for each row
declare
his_car_name varchar(60);
his_car_id number;
begin
select car_code into his_car_id from tablea where car_code=:NEW.his_car_id;
if his_car_id is null then
raise_application_error(-20002,'Invalid Car');
end if;
select max(his_car_name) into his_car_name from tableb where his_car_id=:NEW.his_car_id;
if his_car_name is null then
select car_name into his_car_name from tablea where car_code=:NEW.his_car_id;
his_car_name := his_car_name || '-0000';
end if;
:NEW.his_car_name := substr(his_car_name,1,instr(his_car_name,'-')-1) || '-' || to_char(nvl(substr(his_car_name,instr(his_car_name,'-')+1,60),0)+1,'FM0000');
end trigb;
SQL> select * from tablea;
  CAR_CODE CAR_NAME
         1 Audi
         2 Mercedes
         3 Honda
         4 Toyota
         5 Maruti
SQL> select * from tableb;
no rows selected
SQL> insert into tableb (person_name,his_car_id) values ('Scott',3);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('John',3);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Mike',1);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Smith',4);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Flower',2);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Lewis',1);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Ponting',4);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Bill',1);
1 row created.
SQL> insert into tableb (person_name,his_car_id) values ('Tony',11);
insert into tableb (person_name,his_car_id) values ('Tony',11)
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "SCOTT.TRIGB", line 5
ORA-04088: error during execution of trigger 'SCOTT.TRIGB'
SQL> select * from tableb;
PERSON_NAME                              HIS_CAR_ID HIS_CAR_NAME
Scott                                             3 Honda-0001
John                                              3 Honda-0002
Mike                                              1 Audi-0001
Smith                                             4 Toyota-0001
Flower                                            2 Mercedes-0001
Lewis                                             1 Audi-0002
Ponting                                           4 Toyota-0002
Bill                                              1 Audi-0003
8 rows selected.
SQL>Regards
Girish Sharma

Similar Messages

  • What sequence setting should I use for a High Quality Video Montage?

    I am about to start a new project for a client using photographs only.  I have two questions:
    1.  What should I use for the sequence settings?  Should I edit with a HD sequence setting? 
    2.  I am going to scan the pics myself.  What Pixel or resolution is appropriate to get the best quality?  I'm looking for wide screen 16 x 9, not 3 x 4.

    First, decde how you are going to deliver this production to your client. Then tell us what that delivery medium will be. Then we'll have some advice for you.
    See the section in the FCP manual on using still images. You need to understand that in video there are only pixels, no dots per inch or lines per inch. Those terms are meaningless in video. You wil sand at a size in raw pixels that is only slightly larger than your delivery format.
    bogiesan

  • If I'm using a Canon S110 what sequence preset should I use to get the best high def results?

    Also if I'm uploading these videos to YouTube, should I use the YouTube preset in exporting the video? Will that make my video look high def as well?

    For editing, The NEW ITEM process will ensure that your editing sequence matches your video file
    CS5-thru-CC PPro/Encore tutorial list http://forums.adobe.com/thread/1448923 has a link to learn about the NEW ITEM process
    YouTube Exporting http://forums.adobe.com/thread/1451877?tstart=0

  • Which access sequence of Partner determination should be used?

    Now my company is upgraded from CRM 2.0c to CRM 5.0 HR1. I found the different result about partner determination on business activity (via transaction code: CIC0) between two version.
    <b>On CRM 2.0C</b>
    <b><u>Tcode: CIC0</u></b>
    Enter sold-to party code: 5300001 as activity partner, Contact person:244 on 'BP searching' workspace. Then on 'Maintain Business Transaction' workspace will display  5300001 as activity partner and 244 as Contact person.
    <b><u>Configuration:</u></b>
    Partner Function: 00000015 Contact person (CRM) using Access sequence 0002
    Access sequence 0002 from activity partner
    Dialog seq:10 has partner origin COM_PARTNER_A Preceding document and mark 'Determine in incorrect source partner'.
    Dialog seq:20 has partner origin CRM_PARTNER_D General business partner model and have origin details; Partner Function category '0006 Activity partner' and Usage 'CRM'.
    <b>CIC0 of CRM 5.0 HR1</b>
    <u>Tcode: CIC0</u>
    Enter sold-to party code: 5300001 as activity partner, Contact person:244 on 'BP searching' workspace. Then on 'Maintain Business Transaction' workspace will display  5300001 as activity partner and 66 as Contact person (66 is the first contact person of sold-to party master record:5300001).
    <b><u>Configation:</u></b>
    Partner Function: 00000015 Contact person (CRM) using Access sequence 0002
    Access sequence 0002 from activity partner
    Dialog seq:10 has partner origin COM_PARTNER_A Preceding document and mark 'Allow Incorrect Source'.
    Dialog seq:20 has partner origin CRM_PARTNER_D DO NOT USE - General business partner model and have details on the source; Partner Function category '0006 Activity partner' and Usage 'CRM'.
    Dialog seq:30 has partner origin CRM_PARTNER_C Business Partner Relationship and have details on the source; Partner Function category '0006 Activity partner' and Usage 'CRM'.
    Please suggest me which access sequence should be used for getting the correct contact person (result same as CRM 2.0C).
    Thanks you so much for support.

    Hi,
    to you receive the same result also in CRMD_ORDER, or only in CIC0. Please keep in mind that there is a difference! In CIC0 no pop-ups for selecting partners is executed, so the first contact person is taken (note 487734 gives a modification. Also the partner function of ICAGENT is necessary within CIC0.
    From the view of CRMD_ORDER the following access sequence should be used:
    10     COM_PARTNER_A Preceding Document
    20     CRM_PARTNER_A BP Relationships By Sales Organization  + Wait Flag + Partner Function category '0006 Activity partner' and Usage 'CRM'.
    30     CRM_PARTNER_C Business Partner Relationships + Partner Function category '0006 Activity partner' and Usage 'CRM'.
    Hope that this information is helpful!
    Regards, Gerhard

  • Is there a way to enforce the use of sequences

    is there a way to stop someone from inserting an id without using the sequence?
    CREATE SEQUENCE id_seq
       START WITH 1;
    CREATE TABLE test_table (id_seq NUMBER (4) PRIMARY KEY);
    INSERT INTO test_table
         VALUES (id_seq.NEXTVAL);
    INSERT INTO test_table
         VALUES (2);
    INSERT INTO test_table
         VALUES (id_seq.NEXTVAL);gives us
    ORA-00001: unique constraint (DSAMSTRC.SYS_C0091648) violated
    as it should
    however is there a check constraint of some ilk that ensures that the user is using the sequence when doing inserts?
    so that the second insert
    INSERT INTO test_table
         VALUES (2);gives me some sort of check constraint violation that I'm not using the id_seq.NEXTVAL ?

    Justin:
    One minor problem with your trigger. If the "bad" insert is the first thing done in the session you get:
    SQL> insert into test_table values(25);
    insert into test_table values(25)
    ERROR at line 1:
    ORA-08002: sequence ID_SEQ.CURRVAL is not yet defined in this session
    ORA-06512: at "OPS$ORACLE.TRG_TEST_TABLE", line 4
    ORA-04088: error during execution of trigger 'OPS$ORACLE.TRG_TEST_TABLE'If you want to raise an exception instead of just silently using the sequence as Frank suggests you need something more like:
    create trigger trg_test_table
       before insert on test_table
       for each row
    declare
       l_currval integer;
       no_currval exception;
       PRAGMA EXCEPTION_INIT (no_currval, -8002);
    begin
       select id_seq.currval
       into l_currval
       from dual;
       if( l_currval != :new.id_seq ) then
          raise_application_error( -20001, 'Hey!  Use the sequence' );
       end if;
    exception
       when no_currval then
          raise_application_error( -20001, 'Hey!  Use the sequence' );
    end;John

  • Should I use Compressor 4 before sending over to DVD Studio Pro

    I am making a FCP X movie and when it's finished I want to put it on a DVD using DVD Studio Pro. I have done this before but now I'm wondering if I should first export it to Compressor 4 and then to DVD Studio Pro. I understand that if I was puting it on YouTube or an iPod device I would need to Compress it however why would I need to go to Compresss 4 first if ultimately going to DVD Studio Pro? Would I get a better Codec quality then what I get from exporting in FCP X using their default Compression format i.e. Quicktime? Should I use an Apple ProRes Compression from Compressor 4? I guess I really don't understand the encoding quality options very well however I do want the best quality on my finished DVD. The DVD or Sequence is somewhere around 20 - 25 minutes if that makes any difference in your response.

    This is (at least) a triple post. It's best not to ask the same questions multiple times in multiple forums.
    Russ H

  • Should I use .INI or .XML config files on cRIO?

    I'm looking to make a configuration file for an application running on a cRIO-9022. It will contain a small amount of configuration data (like numeric offsets, file paths, and IP addresses). I have 2 questions:
    1) Which file format should I use (.ini or .xml)? I have used .INI in the past because it is human readable/configurable with notepad, but it seems like .xml is becoming the new standard
    2) I would like to be able to modify config parameters on the PC that connects to the cRIO. What is the best way to modify the config file if it is stored on the cRIO hard disk (FTP the file to PC, make changes, FTP back? Network Streams?)
    --CLD--
    LV 6.1, 8.6.1, 2011 SP1, 2012 SP1

    JimMacD wrote:
    Thanks for the info.
    Any clever ways of accessing and changing the Config File data from a LV application running on a PC that doesn't require manually editing the file? I want the operator to just be able to click a button that says "cRIO Config", open a dialog, and change the values from there.
    uhm.... Yes!
    In This Post I show a bit of my hand on just exactly what I keep in a ini.config file (wel,l 1 section of a config file)  It would be nearly idiotic of me to not provide a Config editer since there are numerous Enum type defs in the delimited value for each key.  so since I, as the developer, know what sections (and possibly keys) are there I can read the file and load them to indicators on a config editor GUI.
    I've actually done this two ways-
    1) a seperate app that only "admin Engineers" know the location of "Launch Config editor.exe.
    2) In the application referanced above I have a button that opens a MODAL panel to edit the file (remember- I know what is in the file).   Users need permissions (Users- Passwords and permissions are kept in a config file, of course!) to even display the "Edit Sequence" button. but the "super user" can edit the step parameters. 
    HINT: one of these "Steps" loads a xml file to expose telnet commands and config for the uP on the DUT.   I expect the firmware on the Linux DUT will change in the future and did not want to rebuild my app whenever a typo was fixed in a command line tool.  BUT, since there are "special characters" that do not fit nicely into a .ini I exposed the telnet commands and line ends IP address and the login script  in a xml file.
    I know this did not directly answer your question!  but It should provide some food for thought.
    If you can share your data structure- I can be more specific. 
    Jeff

  • Using oracle sequence in SQL Loader

    I'm using oracle sequence in control file of sql loader to load data from .csv file.
    Controlfile:
    LOAD DATA APPEND
    INTO TABLE PHONE_LIST
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    PHONE_LIST_ID "seqId.NEXTVAL",
    COUNTRY_CODE CHAR,
    CITY_CODE CHAR,
    BEGIN_RANGE CHAR,
    END_RANGE CHAR ,
    BLOCKED_FREE_FLAG CHAR
    Datafile:
    1516,8,9,9,B
    1517,1,1,2,B
    1518,8,9,9,B
    1519,8,9,9,B
    1520,8,9,9,B
    1521,8,9,9,B
    1) As first column uses oracle sequence, we have not defined that in datafile.
    This gives me error "Can not insert NULL value for last column"
    Is it mandatory to specify first column in datafile, even though we are using sequence?
    2) Another table is referencing PHONE_LIST_ID column (the one for which we using sequence) of this table as a foreign key.
    So is it possible to insert this column values in other table simultaneously? Sequence no. should be same as it is in first table...
    Kindly reply this on urgent basis....

    use BEFORE INSERT trigger
    with
    select your_seq.nextval into :new.id from dual;

  • Use of sequence numbers while inserting into tables

    Hi,
    Consider i have a stored procedure where i insert records into 30 to 40 tables.
    for example i have a table A and a sequence SEQ_A for that table.
    Is there any difference in performance in the following two ways of
    insertion,
    1. select SEQ_A.NEXTVAL into variable_a FROM DUAL;
    INSERT INTO A VALUES(variable_a);
    2.INSERT INTO A VALUES (SEQ_A.NEXTVAL).
    I have 30 to 40 insert statements like that in method 1.
    if i replace it by method 2. will there be any improvement in performance?
    Thanks & Regards
    Sundar

    This could be interesting. I agree that triggers should be used for data integrity, though even better is to only allow write access to tables via stored procedures.
    Anyway while you are waiting for the test case that shows triggers are faster, which could take some time, it is quick and easy to come up with a test case that shows the opposite.
    SQL> create table t (id number, dummy varchar2(1));
    Table created.
    real: 40
    SQL> insert into t select s.nextval, 'a' from all_objects;
    29625 rows created.
    real: 5038
    SQL> rollback;
    Rollback complete.
    real: 40
    SQL> create trigger tt before insert on t
      2  for each row
      3  begin
      4     select s.nextval into :new.id from dual;
      5  end;
      6  /
    Trigger created.
    real: 291
    SQL> insert into t select null, 'a' from all_objects;
    29626 rows created.
    real: 13350
    SQL> rollback;
    Rollback complete.
    real: 1082
    SQL>Note with triggers even the rollback took longer.
    Martin

  • What frame rate timeline should I use for 1080p 60fps premiere pro

    When using 1080p 60fps clips what sequence should I use when creating a timeline that would work the best for slow mo application?
    I read that you should use a 24 fps timeline but i'm not sure?
    Also I have a few 720 @ 120 fps, should I create a separate sequence for that and what kind of timeline should I use since cs5 only has 1080 @ 60fps option?

    24 is a good frame rate for most animations but some people like 30 and for the max stress on user systems and animation smoothness, use 60.

  • Should I use materialised view?

    I am using the following sql in my code. This takes a long time to execute and I need to tune this. Please review and suggest if I should be using a materialized view instead.
    Main Select statement for interest calculation
    SELECT          intratechgcur.SECURITY, intratechgcur.srl_no, intratechgcur.schg_type,
         CASE WHEN intratechgcur.effective_date < ADt_Start_Date THEN ADt_Start_Date
                             ELSE intratechgcur.effective_date END AS start_date,
         CASE WHEN intratechgcur.effective_date < ADt_End_Date
                             AND NVL(intratechgnext.effective_date, ADt_End_Date) > ADt_End_Date THEN ADt_End_Date
                             ELSE NVL(intratechgnext.effective_date, ADt_End_Date) END AS end_date,
                        intratechgcur.rate, intratechgcur.face_value, intratechgcur.listing_int, intratechgcur.comm_prod_int,
                        intratechgcur.sec_create_int, intratechgcur.int_type, intratechgcur.interest_key, intratechgcur.margin,
                        intratechgcur.FLOOR, intratechgcur.cap, intratechgcur.reset_freq, intratechgcur.cmpd_y_n, intratechgcur.cmpd_freq,
                        intratechgcur.comp_type, intratechgcur.int_day, intratechgcur.int_day_1, intratechgcur.int_day_2, intratechgcur.int_dtls_yn
    FROM               v_intratechg intratechgcur, v_intratechg intratechgnext
    WHERE               intratechgcur.SECURITY          = AS_Security
    AND          intratechgcur.effective_date < ADt_End_Date
    AND               intratechgnext.SECURITY          (+)= intratechgcur.SECURITY
    AND               intratechgnext.srl_no          (+)= intratechgcur.srl_no + 1
    ORDER BY      intratechgcur.SECURITY, intratechgcur.effective_date, intratechgcur.srl_no ;
    The code for the view V_intratechg is;
    CREATE OR REPLACE VIEW V_INTRATECHG AS
    SELECT     security,
         schg_type,
         effective_date,
         SUM(1) over (PARTITION BY security ORDER BY security, effective_date ASC, schg_type ASC) AS srl_no,
         face_value,
         rate,
         listing_int,
         comm_prod_int,
         sec_create_int,
         int_type,
         interest_key,
         margin,
         FLOOR,
         cap,
         NVL(reset_freq, 'DAILY') AS reset_freq,
         NVL(cmpd_y_n, 'N') AS cmpd_y_n,
         NVL(cmpd_freq, 'DAILY') AS cmpd_freq,
         NVL(comp_type, 'N') AS comp_type,
         int_day, int_day_1, int_day_2, int_dtls_yn
    FROM
         (SELECT     security.security, 'IM' AS schg_type,
              GREATEST(security.prv_int_dt, NVL(security.allot_date, security.prv_int_dt),
              NVL(security.first_int_date,security.prv_int_dt)) AS effective_date,
              DECODE(intday.int_day_1, 'ACD', NVL((SELECT interest_amt FROM securityschddtls A WHERE security.security = A.security
              AND A.adhoc_schd_date > GREATEST(security.prv_int_dt, NVL(security.allot_date, security.prv_int_dt),
              NVL(security.first_int_date,security.prv_int_dt))
              AND a.rectype ='L' AND A.ADHOC_SCHD_DATE = (SELECT MIN(ADHOC_SCHD_DATE) FROM securityschddtls
    WHERE      securityschddtls.adhoc_schd_date > GREATEST(security.prv_int_dt, NVL(security.allot_date, security.prv_int_dt), NVL(security.first_int_date,security.prv_int_dt))
         AND securityschddtls.security = A.security AND securityschddtls.rectype='L')),
              NVL(secchg.rate, security.interest)), NVL(secchg.rate, security.interest)) AS rate,
              NVL(secchg.face_value, security.face_value) AS face_value,
              NVL(secchg.listing_int, security.listing_int) AS listing_int,
              NVL(secchg.comm_prod_int, security.comm_prod_int) AS comm_prod_int,
              NVL(secchg.sec_create_int,security.sec_create_int) AS sec_create_int,
              NVL(secchg.int_type, security.int_type) AS int_type,
              NVL(secchg.interest_key, security.interest_key) AS interest_key,
              NVL(secchg.margin, security.margin) AS margin,
              NVL(secchg.FLOOR, security.FLOOR) AS FLOOR,
              NVL(secchg.cap, security.cap) AS cap,
              NVL(secchg.reset_freq, security.reset_freq) AS reset_freq,
              NVL(secchg.cmpd_y_n, security.cmpd_y_n) AS cmpd_y_n,
              NVL(secchg.cmpd_freq, security.cmpd_freq) AS cmpd_freq,
              NVL(secchg.comp_type, security.comp_type) AS comp_type,
              NVL(secchg.int_day, security.int_day) AS int_day, intday.int_day_1,
              intday.int_day_2, 'Y' AS int_dtls_yn
              FROM          security, assetype, intday, securityschddtls secdtls,
                        (SELECT     secchg.security AS security, secchg.call_date AS effective_date,
                        NVL(secchg.rate,0) AS rate, secchg.face_value,
                        SUM(1) over (PARTITION BY secchg.security ORDER BY secchg.security,
                        secchg.call_date ASC) AS srl_no,
                        NVL(secchg.listing_int,0) AS listing_int, NVL(secchg.comm_prod_int,0) AS comm_prod_int,
                        NVL(secchg.sec_create_int,0) AS sec_create_int,
                        secchg.int_type, secchg.interest_key,
                        nvl(secchg.margin,0) as margin, nvl(secchg.FLOOR,0) as floor,
                        nvl(secchg.cap,0) as cap, secchg.reset_freq,
                        secchg.cmpd_y_n, secchg.cmpd_freq, secchg.comp_type, secchg.int_day FROM          secchg) secchg
              WHERE          security.asset_type     = assetype.asset_type
                   AND          security.int_day          = intday.int_day
                   AND          assetype.int_y_n           = 'Y'
                   AND          security.rectype          = 'L'
                   AND          assetype.rectype          = 'L'
                   AND          intday.rectype               = 'L'
                   AND          secchg.security (+)= security.security
                        AND          secchg.srl_no (+)= 1
                        AND          secdtls.security (+)= security.security
                        AND          secdtls.srl_no (+)= 1
                        AND          secdtls.rectype (+)= 'L'
              UNION ALL
              SELECT     schedules.security,
                   DECODE(schedules.schd_past_yn, 'Y', 'RP', 'RS') AS schg_type,
                   DECODE(intday.int_day_1, 'ACD',security_cashflow.start_date,security_cashflow.inflow_date) AS effective_date,
                   --commented by vijai
                   -- DECODE(intday.int_day_1, 'ACD', intschdamt.amount, NVL(intratechg.rate,security.interest)) AS rate,
                   DECODE(intday.int_day_1, 'ACD', intschdamt.amount,decode(security_cashflow.start_Date,intratechg.value_Date, intratechg.rate, security.interest)) as rate,
                   decode(nvl(schedules.tot_face_value - schedules.cum_face_value,security.face_value),0,security.face_value,schedules.tot_face_value - schedules.cum_face_value,security.face_value) AS face_value,
                   NVL(intratechg.listing_int,security.listing_int) as listing_int,
                   NVL(intratechg.comm_prod_int,security.comm_prod_int) as comm_prod_int,
                   NVL(intratechg.sec_create_int,security.sec_create_int),
                   NVL(intratechg.int_type,security.int_type) as int_type,
                   nvl(intratechg.interest_key,security.interest_key) as interest_key,
                   nvl(intratechg.margin,security.margin) as margin,
                   nvl(intratechg.FLOOR,security.floor) as floor,
                   nvl(intratechg.cap,security.cap) as cap,
                   nvl(intratechg.reset_freq,security.reset_freq) as reset_freq,
                   nvl(intratechg.cmpd_y_n,security.cmpd_y_n) as cmpd_y_n,
                   nvl(intratechg.cmpd_freq,security.cmpd_freq) as cmpd_freq,
                   nvl(intratechg.comp_type,security.comp_type),
                   nvl(intratechg.int_day,security.int_day),
                   intday.int_day_1, intday.int_day_2,
                   DECODE(intratechg.security, NULL, 'N', 'Y') AS int_dtls_yn
              FROM     v_schedules schedules, security, intday, intratechg, v_schedules intschdamt, security_cashflow
              WHERE     schedules.security          = security.security
              AND          schedules.red_yn      = 'Y'
              AND          security.int_day               = intday.int_day
              AND          security.rectype               = 'L'
              AND          intday.rectype                    = 'L'
              AND          intratechg.security (+)= schedules.security
              AND          intratechg.value_date(+)= schedules.schd_date
              AND          intratechg.rectype     (+)= 'L'
              AND          intschdamt.security (+)= schedules.security
              AND          intschdamt.schd_date (+)= schedules.schd_date
              AND          intschdamt.red_yn (+)= 'N'
              AND           security_cashflow.inflow_type      = 'INT'
              AND           security_cashflow.inflow_date     = schedules.schd_date
              AND           security.security               = security_cashflow.security
              AND           schedules.security          = security_cashflow.security
              UNION ALL
              SELECT     intratechg.security, 'IR' AS schg_type,
                   intratechg.value_date AS effective_date,
                   NVL(intratechg.rate,security.interest),
                   security.face_value,
                   NVL(intratechg.listing_int,security.listing_int),
                   NVL(intratechg.comm_prod_int,security.comm_prod_int),
                   NVL(intratechg.sec_create_int,security.sec_create_int),
                   nvl(intratechg.int_type,security.int_type),
                   nvl(intratechg.interest_key,security.interest_key),
                   nvl(intratechg.margin,security.margin),
                   nvl(intratechg.FLOOR,security.floor),
                   nvl(intratechg.cap,security.cap),
                   nvl(intratechg.reset_freq,security.reset_freq),
                   nvl(intratechg.cmpd_y_n,security.cmpd_y_n),
                   nvl(intratechg.cmpd_freq,security.cmpd_freq),
                   nvl(intratechg.comp_type,security.comp_type),
                   nvl(intratechg.int_day,security.int_day),
                   intday.int_day_1, intday.int_day_2, 'Y' AS int_dtls_yn
              FROM     intratechg, security, intday
              WHERE     intratechg.security          = security.security
              AND     security.int_day               = intday.int_day
              AND     intratechg.rectype          = 'L'
              AND     security.rectype               = 'L'
              AND     intday.rectype                    = 'L'
              AND     NOT EXISTS     (SELECT     1 FROM          v_schedules schedules
                             WHERE          schedules.security     = intratechg.security
                             AND          schedules.schd_date     = intratechg.value_date
                             AND          schedules.red_yn          = 'Y'))
              ORDER BY security, srl_no
    The code for the view V_schedules is;
    CREATE OR REPLACE VIEW V_SCHEDULES AS
    SELECT schdall.security,
              schdall.schd_date,
              schdall.schd_type,
              schdall.percent,
              schdall.units_o,
              schdall.units_n,
              schdall.amount,
              schdall.sequences,
    schdall.act_sch_dt,
         schdall.security_n,
              schdall.prior_act,
         schdall.red_amount,
              schdall.ben_refer,
         schdall.round_method,
    schdall.round_dec,
    schdall.average_y_n,
         schdall.schd_past_yn,
         CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN 'Y' ELSE 'N' END AS red_yn,
         SUM( CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN schdall.red_amount ELSE 0 END)
                                  over(PARTITION BY schdall.security) AS tot_face_value,
    SUM( CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN schdall.red_amount ELSE 0 END)
                                  over(PARTITION BY schdall.security
                                       ORDER BY schdall.security, schdall.schd_date ASC) AS cum_face_value,
         SUM( CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN schdall.red_amount ELSE 0 END)
                                       over(PARTITION BY schdall.security
                                       ORDER BY schdall.security, schdall.schd_date DESC) AS to_be_redeemed ,
              SUM(CASE WHEN schd_type =sysschd.INT THEN 0 ELSE 1 END)
                                       over(PARTITION BY schdall.security,schdall.schd_date,schd_type)
                             AS no_of_schd
    FROM
                   (SELECT      schedules.security_o AS security,
                                  schedules.schd_date,
                                  schedules.schd_type,
                                  schedules.percent,
                                  schedules.units_o,
                                  schedules.units_n,
                                  schedules.amount,
                                  schedules.sequences,
                                  schedules.act_sch_dt,
                                  schedules.security_n,
                                  schedules.prior_act,
                                  schedules.red_amount,
                                  schedules.ben_refer,
                                  schedules.round_method,
                                  schedules.round_dec,
                                  schedules.average_y_n,
                                  DECODE(schedules.schd_type,'RED','Y','Y') AS schd_past_yn
              FROM           schdpast schedules
              WHERE           prior_act = 'A'
              AND                rectype = 'L'
              UNION ALL
              SELECT           schedules.security_o AS security,
                                  schedules.schd_date,
                                  schedules.schd_type,
                                  schedules.percent,
                             schedules.units_o,
                   schedules.units_n,
                             schedules.amount,
                        schedules.sequences,
                        schedules.act_sch_dt,
                   schedules.security_n,
                   schedules.prior_act,
                        schedules.red_amount,
                        schedules.ben_refer,
                   schedules.round_method,
                   schedules.round_dec,
                   schedules.average_y_n,
                        'N' AS schd_past_yn
              FROM           schedules
              WHERE           prior_act = 'A'
              AND                rectype = 'L'
              AND                Process_date IS NULL ) schdall,
              (SELECT           MAX(redschdtype) AS red,
                             MAX(disredtype) AS disred,
                                  MAX(intschdtype) AS      INT
                                  FROM sysparamschd
              WHERE rectype = 'L') sysschd
    ORDER BY security, schd_date, schd_type

    Too much SQL... makes me eyes hurt.
    I think you're running down the wrong alley here. The very first and fundamental principle of performance tuning is identifying the performance problem. Saying that there is a problem is not identifying the actual problem.
    You cannot run down the alley with a knife looking for a performance problem to kill if you do not know how it looks like. Good that you are running though - the old Klingon saying of "a running warrior can slit more throats" hold very true. :-)
    Why is the existing SQL slow? You first need to identify that. Sure, a materialised view can make the end-query much faster as it has no longer to do all the work - that has now been done in batch by a DBMS_REFRESH job updating and maintaining that materialised view. But that work is still done... so have you actually fixed the cause of the performance problem, or merely hid it by addressing the symptoms?
    How does one find and identify the underlaying performance problem with too-much-SQL-that-makes-Billy's-eyes-hurt? Software Engineering 101. Take any complex problem. Break it down into lots of smaller little problems. Solve each on in turn.
    Take the SQL, break it down into simpler pieces and check each for performance issues. Look at the execution plan and cost. Determime if you (via the physical db design) are providing optimal I/O paths to the CBO in order for it to get to the required data with as little I/O as possible.
    Once you deal with the facts, you can make an informed decision or whether or not a materialised view will actually fix the cause of the performance problem.

  • SOA 11g DBAdapter Polling using a Sequencing Table with a DATE Field

    Hi.
    I have implemented a polling solution using a sequencing table that references a DATE column. For the most part the poll works correctly, but on occasion, I am not seeing a BPEL process instantiation for various records that get created in my source table.I have also noticed that in this particular case, the DATE field content on one or more source records is exactly the same --> "YYYYMMDDhhmmss".
    I just want to confirm here, that the polling adapter should be able to pick up multiple records from the source table, even though the date field is exactly the same. As well, how should I go about trying to debug this issue, if point #1 is handled by the system. Is there is a specific log or trace file that I can look at. Also, could I be facing a timing issue ?
    Can someone please comment on this.
    Thanks.

    In my table, I don't see a primary key, but only a unique index. I would assume then, that this would be analogous to the primary key capture; noticed that currently this code was only using one column out of two, from the unique index itself.
    Also, is the date content issue that I mentioned above a moot point then, based upon not having the correct primary key/unique key data pointers established ?
    Thanks.

  • How to use ODI sequences ??

    I have an interface which need an ODI sequence.
    When I execute it the value of the sequence is always the same.
    I have seen on another thread that it may pass by an agent but...
    I have 2 tables (source and target) from the same connexion which don't and won't have agent.
    How can I do ??
    My connexion is on an Oracle 10g RDBMS and I'm using an IKM SQL Control Append.
    This is not the first time I have problem with the ODI Sequence but this time I can't create an RDBMS one ...
    Thanks in advance,
    BM

    Hi guys,
    I have some questions, I am trying to create a dimension and it should use a sequence, but I am getting the same issue as you guys. I can't not generate a unique key because my sequence is the same value for all rows.
    So if I really understood there are two ways to use a sequence in ODI. One is using ODI sequence (creating it inside ODI) and other is using a RDBMS sequence.
    First: What I have to do to use a RDBMS sequence? (Step by step please)
    Second: I can't use an IKM SQL to SQL append in my interface. This interface is pretty simple - source is a flat file target is an Oracle table, I just need to move all flat files columns to Oracle table adding a sequence. I understood that my Staging area should be different than my Target area based on posts above. I already created a new datastore to be my new staging area, but I don't know how to make an association between interface and new stage area.
    Can you please provide me the easiest solution?
    Thanks
    Leo

  • MacBook should be used as a VMWare environment?

    In my work, I am be assigned as Windows server administrator.
    I want to learn Windows server technoligy.
    I installed VMWare Fusion in my MacBook Air 2013 mid. But sometimes, I think
    why I take work into my personal life? Why use my own Mac to do my company's
    tech?
    Should I use MacBook Air as it is? (for example, picture, music, internet)
    or
    someone also use the powerfull computer to learn Windows?
    Thank you.

    You can try using the Numeric Limit step type inside of your for each loop by usign one array to set the limits to compare with other array serving as your data source.
    Any sequence can be used as a subsequence by using the Sequence Call step. You can call a sequence from the current or a different sequence file. Please refer to this Help article for more information.
    Regards,
    Anjelica W.
    National Instruments
    Applications Engineer

  • What should I use as parameter name in call.addParameter in WS DII client

    I'm using dynamic invocation interface to call a web service in Oracle OC4J.
    The part of WSDL "Types" is:
    <element name="myType" type="tns:myType" />
       <complexType name="myType">
         <sequence>
           <element name="sss" nillable="true" type="string" />
         </sequence>
      </complexType>
    ...My J2SE client has following code I belive create problem:
    call.addParameter("sss", input,MyType.class, ParameterMode.IN);when I invoke the web service, I got error:
    javax.xml.rpc.soap.SOAPFaultException: caught exception while handling request: unexpected element name: expected={http://mypackage/B2BGateway/types}myType, actual=sss
    I changed my code according to this message as it expected to be:
    call.addParameter("{http://mypackage/types}myType",
         input,MyType.class, ParameterMode.IN);I got :
    HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Error parsing envelope: (2, 179) Expected name instead of {.
    seems the "{" should not be part of parameter name.
    Then, what should I use as parameter name.
    BTW, the web service server side code should works fine as I can test it with others client.
    Thanks

    Moved one step further:
    I changed abit to code:
    call.addParameter("myType", input,MyType.class, ParameterMode.IN);I can see the server side got SOAP request:
       <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <env:Body>
             <myType>
                <ans1:sss xmlns:ans1="http://mypackage/types/">abc</ans1:sss>
             </myType>
          </env:Body>
       </env:Envelope>As you can see, the problem in the generated request is "myType" does not have namespace
    Could someone tell me how to fix it.
    Thanks
    Edited by: John618 on Feb 21, 2009 5:03 PM

Maybe you are looking for