Trigger, sequence and partitions

Hello,
anyone can suggest me a way to check table partition filling by use of pre-insert trigger on partitioned table:
when inserting row, I check with a sequence if this row is in what partition, and if it reachs partition bound, before inserting new row I execute a DDL statement, in autonomous transaction, in which I truncate partition.
I encounter DML table lock due to trigger firing for insert.
I'm trying not to change current business logic that wants to perform such checks automatically and not by external PL/SQL procedure that I have to start manually.
Thanks
Paolo P.

Solved

Similar Messages

  • Task Sequence Windows Server 2012 format and partition issue when using MDT2012

    Hi all,
    Currently I'm working on a task sequence to deploy a Windows Server 2012 image. We've integrated MDT2012 Update 1 in SCCM2012 SP1 and created a default 'Server Task Sequence'. This task sequence deploys the install.wim to a server which has multiple disks
    attached.
    We've configured multiple format and partition disk steps to create the following partition layout:
    Disk 0: 499MB BDEDrive (do not assign drive letter) + 40GB OSDisk
    Disk 1: 40GB Programs
    Disk 2: 40GB Data
    Disk 3: 25GB User
    When the task sequence is finished I've noticed the drive letters assigned to the disk are not correct. In some cases the BDEdrive gets drive letter D assigned, sometimes drive letters are assigned starting with E, thus skipping drive
    letter D. 
    The smsts.log files show an error when it's re-assigning drive letters after booting into Windows. Looks like an error in the DiskPartScript.txt.
    <![LOG[==============================[ OSDSetupHook.exe ]==============================]LOG]!><time="16:59:40.889-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776"
    file="osdsetuphook.cpp:186">
    <![LOG[Executing task sequence]LOG]!><time="16:59:40.905-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776" file="osdsetuphook.cpp:279">
    <![LOG[Loading the Task Sequencing Environment from "C:\_SMSTaskSequence\TSEnv.dat".]LOG]!><time="16:59:40.920-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776"
    file="basesetuphook.cpp:366">
    <![LOG[Environment scope successfully created: Global\{51A016B6-F0DE-4752-B97C-54E6F386A912}]LOG]!><time="16:59:40.936-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776"
    file="environmentscope.cpp:659">
    <![LOG[Environment scope successfully created: Global\{BA3A3900-CA6D-4ac1-8C28-5073AFC22B03}]LOG]!><time="16:59:40.936-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776"
    file="environmentscope.cpp:659">
    <![LOG[Debug shell is enabled]LOG]!><time="16:59:43.806-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776" file="basesetuphook.cpp:1440">
    <![LOG[Successfully enabled debug command shell support.]LOG]!><time="16:59:43.884-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776" file="debugwindow.cpp:156">
    <![LOG[Configuring local administrator account]LOG]!><time="16:59:43.884-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776" file="basesetuphook.cpp:1462">
    <![LOG[Re-assign all drive letters...]LOG]!><time="16:59:43.884-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776" file="diskutils.cpp:1941">
    <![LOG[Executing command line: "C:\WINDOWS\system32\diskpart.exe" /s "C:\WINDOWS\TEMP\DiskPartScript.txt"]LOG]!><time="16:59:43.900-120" date="05-10-2013" component="OSDSetupHook" context=""
    type="1" thread="776" file="commandline.cpp:827">
    <![LOG[Process completed with exit code 2147942487]LOG]!><time="16:59:50.249-120" date="05-10-2013" component="OSDSetupHook" context="" type="1" thread="776" file="commandline.cpp:1123">
    <![LOG[Diskpart.exe STDOUT:
    Microsoft DiskPart version 6.1.7601
    Copyright (C) 1999-2008 Microsoft Corporation.
    On computer: SRV03
    Volume 1 is the selected volume.
    DiskPart successfully removed the drive letter or mount point.
    The volume you selected is not valid or does not exist.
    There is no volume selected.
    ]LOG]!><time="16:59:50.249-120" date="05-10-2013" component="OSDSetupHook" context="" type="3" thread="776" file="diskutils.cpp:1807">
    When I take a look at the generated diskpart_script.log file the volume D gets selected twice, which fails the second time because of the first remove drive letter command.
    This is the output in the diskpart_script.log file:
    select volume D
    remove letter=D
    select volume D
    remove letter=D
    select volume E
    remove letter=E
    select volume F
    remove letter=F
    select volume H
    remove letter=H
    select disk 0
    select partition 1
    assign
    select disk 1
    select partition 1
    assign
    select disk 2
    select partition 1
    assign
    select disk 3
    select partition 1
    assign
    It seems this error is caused by the first 'Format and Partition Disk' step before the 'Use Toolkit Package' step which is part of the default Server Task sequence. When I disable this Format and Partition step and create the partition manually
    all looks ok showing no errors in the smsts.log file.
    I've solved this by replacing the first 'Format and Partition Disk' step by an Powershell command which formats and partitions the disk. 
    Anyone seen this behavior?

    I have a similar problem when I install windows on some clients. Have you found any explanation for the behavior?

  • Creation of sequence and trigger for each table!!!!!!!1

    Hi
    I am new to trigger and Sequence field. In one of my database we have many tables with fields for specifing ID numbers. Iam planning to insert the ID field with help of a Sequence and trigger...that trigger fires by adding the sequence value from the dual table. Now the point is here we r having around *60* table with ID field. And i am planning use the above process for each table by creating sequences and trigger for each table.
    Will this affects the performance of database.
    Is there any other option other than the above process, I mean other than creating sequences and trigger for each table.
    PLzz help to resolve this issuee......
    Shiyas
    Edited by: user13170361 on Jun 7, 2010 12:37 AM

    Tiger, I didn't mind about your comment, but the point is try to use
    select NVL(max(a) + 1,1) into i from p1_temp;This line in your trigger code and see what is happening. The problem is with your trigger. You are using group by function and you will not get no_data_found !
    For more help, this is some modification of your code.
    SQL> create table p1_temp (a number(10) primary key, b number(10));
    Table created.
    SQL> create or replace trigger trg_p1_temp
      2  before insert on p1_temp for each row
      3  declare
      4  i number(10);
      5  begin
      6  begin
      7  select NVL(max(a) + 1,1) into i from p1_temp;
      8  exception
      9  when no_data_found then
    10  i := 1;
    11  end;
    12  :new.a := i;
    13  end;
    14  /
    Trigger created.
    SQL> insert into p1_temp(b) values (1);
    1 row created.
    SQL> insert into p1_temp(b) values (2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from p1_temp;
             A          B
             1          1
             2          2
    SQL> Edited by: Saubhik on Jun 7, 2010 2:30 AM

  • Oracle jdbc creating a table, sequence and trigger

    I'm trying to create a table with a sequence and with a trigger for that sequence. When I do this within Oracle Express edition I have the following SQL statements. Which DO run correctly inside Oracle Express using the same user I log in with JDBC.
    CREATE table "TEST" (
    "ID" NUMBER(10) NOT NULL,
    "NAME" VARCHAR2(20),
    constraint "TEST_PK" primary key ("ID")
    CREATE sequence "TEST_SEQ"
    CREATE trigger "BI_TEST"
    before insert on "TEST"
    for each row
    begin
    if :NEW."ID" is null then
    select "TEST_SEQ".nextval into :NEW."ID" from dual;
    end if;
    end;
    So now what I do is put each of these into a List of Strings and execute 1 by one like this:
    List<String> commands = new ArrayList<String>(4);
    commands.add("Create table ...");
    commands.add("Create sequence ...");
    commands.add("Create trigger...");
    st = con.createStatement();
    for (String command : commands) {
    st.execute(command);
    etc...
    But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"
    It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?
    TIA

    SproketBoy wrote:
    But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"Keep in mind: Oracle is not lying to you.
    >
    It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?No, DDL commands cause an explicit commit. As soon as you invoke them, the change is permanent. If it was a rights problem, you'd get a different ORA error stating that, it won't silently fail.
    Lets not assume it is anything difficult, perhaps there is simply a typo in a name somewhere?

  • Suppress auto sequence and trigger DDL for surrogate keys?

    Is there a way to suppress trigger and sequence creation for surrogate keys when export to DDL file?
    I know most of the time the automatic sequence and trigger creation is welcome and very handy.
    However I'm migrating from an old Designer model and there only the needed sequences are created.
    They have a different name and trigger logic is custom (and  generated outside designer).
    There is a lot of package code depending on this. So I prefer to create and use different sequences.
    Is there a way to achieve this? Any tips are welcome.Create

    Hi,
    Note that generating the DDL for Oracle 12c means that it will attempt to use your Oracle 12c Physical model.  So if you normally use Oracle 10g or 11g, you will find that any details from your Oracle 10g or 11g Physical Model will not be included.  So this approach may have other implications for you.
    If you are not using Oracle 12c, there are some relevant properties on the Auto Increment tab of the Relational Model properties dialog for the Column which may help:
    Sequence Name - allows you to specify the name of the Sequence (which can be the name of a Sequence defined in the relevant Physical Model).
    Trigger Name - allows you to specify the name of a Trigger (which can be the name of a Trigger that is defined for the Table in the Physical Model).
    Generate Trigger - unsetting this will stop the Trigger being generated.
    David

  • Sequence and trigger

    Hello,
    Ia have created a Sequence and a trigger
    The Sequence ïs:
    CREATE SEQUENCE "WABO"."WABO_VERG_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 ORDER NOCYCLE;
    The trigger is:
    create or replace
    TRIGGER WABO.WABO_VERGUNNING_TRIC
    BEFORE INSERT ON WABO.WABO_VERGUNNING FOR EACH ROW
    WHEN (new.WABO_ID IS NULL) BEGIN
    SELECT WABO_VERG_SEQ.NEXTVAL INTO :new.WABO_ID FROM dual;
    END;
    When I insert a row in the table the sequence counter is 21 and it's stay's 21 even when I insert a new row
    When I cal the DDL it's showes me this
    CREATE SEQUENCE "WABO"."WABO_VERG_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 ORDER NOCYCLE;
    What am I doning wrong.
    Thanks

    Solved

  • JDeveloper 10g Creating a new record with trigger sequence primary key

    Hi there, I'm sorry to post this incredibly simple question and I'm sure that someone must have answered this on this forum before but the searching of this site is incredible slow and painful and after 30 mins I can't find help.
    I am using a struts Data Action to create a new record in the database and then being forwarded to an edit page where I can enter the new details. Then when the details are entered I am clicking an update button and returning to a browse screen where I can either commit the change to the database or rollback. Sounds pretty simple but I am really struggling with trying to get the trigger of the number sequence to work properly.
    Ideally I would like to click the create new record button and then the primary key/triggered sequence number is already displayed on the empty form...
    ... but if this is too tricky or not possible then I would like the user to either not enter any value in the key field (which currently causes error - JBO-27014: Attribute PoNo in PO_SYS_MODULE.PoSystemView1 is required) OR the user enters a number and the trigger overwrites this number with the next in the sequence.
    I can enter a new record if I look in the manager console and see the next number in the sequence and then create the record using this number and then click commit twice, as the first time I get the error: JBO-25019: Entity row of key oracle.jbo.Key[154 ] not found in PoSystem. Or if I enter a value 5 times greater than the next in the sequence I have to click the commit button 5 extra times to get the sequence to match the input.
    I hope that this lengthy explanation fills you in on my problem, there must be a simple solution to this and I will be VERY grateful to anyone who can help me.
    Many thanks
    Ben Sayers (clearly a newbie)

    Hi,
    ADF Business Components handles this for you - unless yo prefer doing this manually. In the Entity Object, set the PK attribute's type to DBSequence. Then create a database sequence and use a database trigger to add the sequence value on insert
    Frank

  • MDT Config UEFI Specific disk and partition?

    Installing Win8.1 with MDT2013 on UEFI enabled machines everything seems to be ok.. Until... Injecting drivers. The deployment cannot proceed because of destination disk. Sounds obvious because Uefi makes multiple partitions unlike non-uefi that can be installed
    on the first partition.
    I've created an extra step to the "Format and partition disk" and named it "Format and Partition Disk - UEFI". In this step I've set an option "Task sequence variable IsUEFI equals True". So when it is "True" the step
    will format the drive in GPT (as is required for UEFI boot). This seems to work good. I see in the installation the step "Format and Partition Disk - UEFI" when it's a uefi machine, and the original step if it is a non uefi machine. Obviously the
    original step will have also an option "Task sequence variable IsUEFI equals False".
    The problem comes when we get to the step "Install Operating System". Here I made the same change like I did above. (added extra step with extra option:
    The original step "Install Operating System" will have install location: "Specific disk and partition"
    Disk 0 Partition 1.
    The added step will have install location "Specific disk and partition"
    Disk 0 Partition 3. (Because UEFI has multiple partitions)
    For some reason the deployment will accept the step "Format and Partition Disk - UEFI" but in the install step it will take the "Install Operating System - Legacy" (so it will try to install to disk 0 partition 1 as I see in BCD log).
    Is there any reason that the same condition  works at the format step and not at the install step?
    We choose the option install to "Specific disk and partition" because of problem when have the location set at "logical drive letter stored in a variable" (problem described:
    link)

    Solution in my case was going for the "logical drive letter stored in a variable" instead of "Specific disk and partition".
    Note when applying this: must keep using "OSDisk" variable or it will throw errors (problem described in
    this link)
    So I deleted the "UEFI" steps, and renamed the "Install Operating System - Legacy" to before. Removed the query for the IsUEFI variable. MDT will automatic install to MBR or GPT based on device.

  • Help on Sequence and Procedure

    Hi all,
    I have a situation like this
    I have 10 different tables like a,b,c,d,e,f
    But i have same columns in all tables
    like
    id
    Created_date,
    Current_user,
    updated_by,
    updated_date
    I created a sequence and triggers on a table like below
    CREATE SEQUENCE x_SEQUENCE START WITH
    150001 INCREMENT BY 1 MAXVALUE 999999
    CYCLE;
    CREATE TRIGGER xi_trigger
    BEFORE INSERT ON x_table FOR EACH ROW
    BEGIN
    SELECT x_SEQUENCE.NextVal,USER,SYSDATE INTO :NEW.CTUT_ID,
    :NEW.CURRT_USER_ID,:NEW.CREATED_DATE FROM DUAL;
    :NEW.CREATED_BY := :NEW.CTUT_ID;
    END;
    CREATE TRIGGER xU_trigger
    BEFORE UPDATE ON x_table FOR EACH ROW
    BEGIN
    SELECT USER,SYSDATE INTO :NEW.CURRT_USER_ID,:NEW.UPDATED_DATE FROM DUAL;
    :NEW.UPDATED_BY := :NEW.CTUT_ID;
    END;
    everything is working fine for one table
    1) Can anybody help me how to create a procedure with Trigger code
    so that i can call that procedure in all tables
    like
    CREATE TRIGGER xi_trigger
    BEFORE INSERT ON x_table FOR EACH ROW
    BEGIN
    x_procedure;
    end;
    2) When sequence is completed i mean when it reach max value how to display message
    Thanks for your help

    Here's one way of doing it:
    CREATE PROCEDURE audit_action
      ( pn_id OUT NUMBER
        , pv_by OUT VARCHAR2
        , pd_on OUT DATE )
    IS
       ln_seq NUMBER;
       ld_on DATE;
       lv_by VARCHAR2(30);
       x_seq exception;
       pragma exception_init(x_seq, -8004);
    BEGIN
       SELECT my_seq.NEXTVAL, USER, SYSDATE
       INTO   ln_seq, lv_by, ld_on
       FROM   dual;
       pn_id := ln_seq;
       pv_by := lv_by;
       pd_on := ld_on;
    EXCEPTION
       WHEN x_seq
       THEN
          RAISE_APPLICATION_ERROR(-8004, 'MY_SEQ has run out of numbers!');
    END audit_action;
    /and here's how you call it:
    CREATE TRIGGER xi_trigger
    BEFORE INSERT ON x_table FOR EACH ROW
    BEGIN
        audit_action (:NEW.ctut_id, :NEW.currt_user, :NEW.created_date);
    END xi_trigger; Warning: I have not run this code (can't be bothered with the set-up) but it is logically correct, so it should work with (at worst) minor syntactical tweaking.
    Cheers, APC
    P.S. CURRENT_USER is a misleading column name, it ought to be called CREATED_BY.
    P.P.S. It is very bad practice to have sequences run out at all. Unless you have a very good reason I strongly urge you not to set MAXVALUE when you create your sequences.

  • IB Queue: Can a Queue be Unordered and Partitioned at the same same time?

    Hi,
    My question is related to Unordered Queue:
    Can a Queue be Unordered and Partitioned at the same same time?
    From PeopleBooks: Managing Service Operation Queues
    "Unordered:
    Select to enable field partioning and to process service operations unordered.
    By default, the check box is cleared and inbound service operations that are assigned to a queue are processed one at a time sequentially in the order that they are sent.
    Select to force the channel to handle all of its service operations in parallel (unordered), which does not guarantee a particular processing sequence. This disables the channel’s partitioning fields.
    Clear this check box if you want all of the queues’s service operations processed sequentially or if you want to use the partitioning fields."
    This seems to indicate that Unordered queues don't use partitioned fields. Yet, there are a few delivered Queues that are Unordered and have one or more Partition fields selected.
    EOEN_MSG_CHNL
    PSXP_MSG_CHNL
    SERVICE_ORDERS
    How does partitioning work in this case? Or is partitioning ignored in such cases?
    Thanks!

    I guess you could use reflection and do something like the following:
    import java.lang.reflect.Constructor ;
    import java.lang.reflect.Method ;
    public class MyClass<T> implements Cloneable {
      T a ;
      public MyClass ( final T a ) {
        // super ( ) ; // Superfluous
        this.a = a ;
      public MyClass<T> clone ( ) {
        MyClass<T> o = null ;
        try { o = (MyClass<T>) super.clone ( ) ; }
        catch ( Exception e ) { e.printStackTrace ( ) ; System.exit ( 1 ) ; }
        o.a = null ;
        //  See if there is an accessible clone method and if there is use it.
        Class<T> c = (Class<T>) a.getClass ( ) ;
        Method m = null ;
        try {
          m = c.getMethod ( "clone" ) ;
          o.a = (T) m.invoke ( a ) ;
        } catch ( NoSuchMethodException nsme ) {
          System.err.println ( "NoSuchMethodException on clone." ) ;
          //  See if there is a copy constructor an if so use it.
          Constructor<T> constructor = null ;
          try {
            System.err.println ( c.getName ( ) ) ;
            constructor = c.getConstructor ( c ) ;
            o.a = constructor.newInstance ( a ) ;
          } catch ( Exception e ) { e.printStackTrace ( ) ; System.exit ( 1 ) ; }
        } catch ( Exception e ) { e.printStackTrace ( ) ; System.exit ( 1 ) ; }
        return o ;
      public String toString ( ) { return "[ " + ( ( a == null ) ? "" : a.toString ( ) ) + " ]" ; }
      public static void main ( final String[] args ) {
        MyClass<String> foo = new MyClass<String> ( "zero" ) ;
        MyClass<String> fooClone = foo.clone ( ) ;
        System.out.println ( "foo = " + foo ) ;
        System.out.println ( "fooClone = " + fooClone ) ;
    }

  • Sequence and Integrity

    as developer which is newly use oracle.. I have confusion
    It is sequence.
    in contrast with MySQL or SQL Server, db system I had work in, oracle didn't have auto increment column instead oracle has sequence
    I think sequence and id column have link, but I get confused cause there no link between both
    someone could insert id without sequence
    after that I search this forum and found out
    remedy of this is trigger. place trigger for insert operation
    What is the best pratice for sequence? particulary when I create table
    thanks & regards

    Hi Hemanth,
    One Question on the below descriptive
    A Sequence can be shared across multiple sessions and sessions do not have to "wait" on each other to increment sequence values.
    A Trigger is one way to implement a Sequence to set a Column Value.
    {code}
    Looking into the above statements and usage, we might get Gap Sequence (no exactly gap but a failing issue with primary key if we handle sequence with triggers) - When handling with multiple Sessions with triggers.
    Let me know your inputs on that.
    - Pavan Kumar N
    Oracle 9i/10g - OCP
    http://oracleinternals.blogspot.com/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SCCM 2012 OSD Fails After Formatting and Partitioning Disks

    Hello,
    The problem is that when I deploy the task sequence to a computer, it loads to WindowsPE properly, then continues to formatting the hard disk and partitioning. After it has finished partitioning it then goes to the applying
    the operating system portion of the task sequence. Finally it errors out with "...Image has failed with the error code (0x80070002)...". What is left on the WinPE is two log files in the SMSTSLog directory, smsts.log and wpeinit.log. Neither of these
    seemed to show anything blatantly obvious to me, but I'm sure there is still some funny things happening. 
    This is my first time posting to a help forum of any kind so any constructive criticism is very welcome! Thanks for helping in advance, since SCCM has probably been the most challenging software I have had to setup. I
    definitely need the help.
    Apparently I can't just throw in all of my logs at once, so I shortened the smsts.log and removed the wpeinit.log. So just say if you need them I guess.

    It's probably your network access sccount!<o:p></o:p>
    "To configure the Network Access Account, open the CM2012 R2 console, click on Administration,
    expand Overview, expand Site Configuration,
    click Sites, on the top ribbon click Configure
    Site Components, click Software Distribution.<o:p></o:p>
    Click on the tab Network Access Account,
    choose Specify the account that accesses network locations (by default the option is set to Use
    the computer account of Configuration Manager client). Click on the orange icon and add the user account that enough permissions to access the content which is required
    while deploying Operating System."<o:p></o:p>
    This account should have the minimum appropriate permissions on operating system deployment content it needs to access. This account
    is important because the computer receiving the operating system does not have a security context it can use to access content on the network.<o:p></o:p>

  • Trigger/Sequence not in ddl preview when comparing models

    Hi,
    I've a problem with incremental DDL generation and trigger/sequence (auto-increment).
    First case :
    I've created a table and generated it in my Oracle database.
    Then, I've defined on my primary key column the "Auto-increment" and "Identity column" to Yes (and of course sequence and trigger names filled).
    If I generate DDL (File/Export or Generate DDL button), no problem. The DDL script contains the sequence and trigger defined in auto-increment properties.
    But if I compare my model and the database (Import data dictionnary, swap target...), the sequence and the trigger are not in the DDL preview.
    Second case :
    If I create a new table in my relational model, with filled auto-increment properties, and then I compare model and db, the new table is created, with associated sequence and trigger. This is completely normal.
    Last case :
    A trigger manually defined in physical model is not in DDL preview if the table already exists in database. If the table doesn't already exist in db, all statements (table, sequence, trigger) are generated.
    my conclusion : auto-increment properties are not taken into account in the incremental DDL generation if the table already exists.
    Can you confirm this ?
    thanks
    regards
    Fabrice
    (Data modeler 3.1.4)

    Hi Fabrice,
    A trigger manually defined in physical model is not in DDL preview if the table already exists in database.Yes. This is true.
    my conclusion : auto-increment properties are not taken into account in the incremental DDL generation if the table already exists.The actual situation is that auto-increment properties are not taken into account in the incremental DDL generation if the column already exists.
    David

  • Trigger sequence

    I need to put a trigger on a table where each time the fk number changes the sequence starts over again. Such as if fk is 12345 and has 3 different tier, the the sequences for it should show fk 12345, squence 1, tier_from 0, tier_to 1000. the next line should show fk 12345 squence 2, tier_from 1001, tier_to 2000. then next line of data should show fk 12345, sequence 3, tier_from 2001, tier_to 3000. then when the fk changes to 23456 then the data should start over. such as
    fk 23456, sequence 1, tier_from 0, tier_to 100, then next line of data should show fk 23456, sequence 2, tier_from 101, tier_to 200.
    Below is the code I wrote. if I can get any help writing the trigger to do this it would be greatly appreciated. I will keep doing my research to see if I can figure it out.
    create sequence tier_seq MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 INCREMENT BY 1 CACHE 20;
    create table tier
    rebate_group_number_fk NUMBER
    ,tier_order_sequence NUMBER
    ,tier_from NUMBER
    ,tier_to NUMBER
    ,tier_per NUMBER
    ,tier_uom VARCHAR2(6)
    ,sliding VARCHAR2(1)
    ,rate NUMBER
    ,rate_type VARCHAR2(1)
    ,constraint rebate_group_tier_fk
    foreign key (rebate_group_number_fk)
    references rebate_group (rebate_group_number_gk)
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
    INITIAL 163840 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
    FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
    create or replace trigger tier_tr before insert on tier for each row begin
    select tier_seq.nextval
    into :new.tier_order_sequence
    from dual
    where rebate_group_number = :new.rebate_group_number_fk;
    end;
    alter trigger tier_tr enable;

    Geez... horrible.
    What do you think will happen if the trigger changes the sequence and the transaction is rolled back? Wrong sequence number used by the next transaction.
    What do you think happens when multiple transactions happen at the same time - each trying to make a change to the sequence?
    Never mind the facts that a sequence need a DDL and implicit transaction to change, how on earth do you expect to address the issue of concurrency? A database (like Oracle) does not only have a single user and single client session at a time. There can be 1000's of users and sessions - and many of them can be execute the very SAME code at the very SAME time.
    Your application design and code needs to be multi-process aware and thread safe. And this approach you have in mind is not. It is flawed. And fundamentally so.
    A sequence is used to generate unique values for surrogate keys. Not grap free values. Not even ascending numeric values (which you will find on Oracle RAC). But UNIQUE values.
    From a data modeling perspective, it also does not make any sense. How can a data model enforce a specific numbering order? Why does the actual generated numeric value for a tier have a specific meaning?
    I cannot see anything correct in this approach, or in the data modeling behind it...

  • Use the default format and partition step to format disk0 partition 1 in multiple disks sutiation

    As we know,we need to disable the default format and partition step in ts to let mdt deploy os on C and leave the other partitions stay safe when there is only one disk on pc,and the way of installing operation system is logical drive letter store in a varible.
    But what if there are 2 disks on pc,and for a record the disk 0 is always the OS disk,don't need to confirmed this.How can we modify the format and partition step to format only C on disk0 under this condition?then lead the mdt to do the rest deployment
    by itself.
    Thanks

    You are pushing up against the design limits of MDT, and the more complex and/or arbitrary the disk configuration the harder it is for MDT to perform installations.
    If you want to maintain the *existing* disk configuration, and just update the OS present, then the recommended course of action is to run MDT from *within* the OS (cscript.exe
    \\server\deploymentshare$\scripts\litetouch.vbs), not from WinPE. When you do this, it's called a "refresh" scenario. MDT can capture the user files via USMT, and it knows which
    partitions to use, because it's launched from within the OS itself.
    Disabling the default Format and Partition step has other unintended consequences.
    Keith Garner - Principal Consultant [owner] -
    http://DeploymentLive.com

Maybe you are looking for