Inserting a Sequence of Numbers

Hi all
I have a number field restricted to 3 digits, and when someone navigates to the block to insert a record I want the number field to display 001 to state this is the first record, then if a second record is inserted put in 002 etc. Currently you can go and put any old 3 digit number in but I want to restrict it to a display field only, showing the number of records in this block in a sequence, for a particular parent record.
I am trying to work out the following:
How to build a counting generator (the most obvious bit)
How to get the count generator to recognise what the existing number is (related to the parent record) and insert the next sequence of number say it is 001, then it now needs to put in 002.
I currently have this piece of code (and result) as a start and am finding it difficult to decide how to build on it from that:
SELECT ltrim (to_char (rownum, '009'))
FROM dual
LTRI
001
Any ideas on this would be appreciated.
Thanks
USER605593

If you had a date column which held the date the row was added (or whatever it is that denotes the order) then you don't need to bother with an explicit sub sequence in the table.
eg.
with my_data as (select 1 record_id, 'hello' val, trunc(sysdate) -1 date_inserted from dual union all
                 select 1 record_id, 'there' val, trunc(sysdate) -1 + 2/24 date_inserted from dual union all
                 select 1 record_id, 'sailor' val, trunc(sysdate) -1 + 5/24 date_inserted from dual union all
                 select 1 record_id, 'boy' val, trunc(sysdate) -1 + 18/24 date_inserted from dual union all
                 select 2 record_id, 'hi' val, trunc(sysdate) -1 + 1/24 date_inserted from dual union all
                 select 2 record_id, 'ho' val, trunc(sysdate) -1 + 12/24 date_inserted from dual union all
                 select 2 record_id, 'off to work' val, trunc(sysdate) -1 + 13/24  date_inserted from dual union all
                 select 2 record_id, 'we go' val, trunc(sysdate) -1 + 23/24  date_inserted from dual union all
                 select 3 record_id, 'good' val, trunc(sysdate) -1 + 1.5/24 date_inserted from dual union all
                 select 3 record_id, 'bye' val, trunc(sysdate) -1 + 5/24 date_inserted from dual union all
                 select 4 record_id, 'geronimo' val, trunc(sysdate) -1 + 4/24 date_inserted from dual)
-- end of data setup. Query below:
select record_id, val, row_number() over (partition by record_id order by date_inserted) rn
from   my_data
RECORD_ID     VAL     RN
1     hello     1
1     there     2
1     sailor     3
1     boy     4
2     hi     1
2     ho     2
2     off to work     3
2     we go     4
3     good     1
3     bye     2
4     geronimo     1This has the added advantage that if you need to insert a row at the end or in the middle, the ordering will automatically be taken care of. If you store the number, you then have to work out a way of updating the sub-sequence number manually. (Obviously, you'll have to format the rn into the 3 digit format for your display purposes, but you already know how to do that.)

Similar Messages

  • Insert the sequence number in table

    Hi..i created one table and i want to insert the sequence num in one column using sql query is it possible? please help me

    Try this..
    SQL> create table t1(x number);
    Table created.
    SQL> create sequence seq_x;
    Sequence created.
    SQL> insert into t1 values(seq_x.nextval);
    1 row created.
    SQL> /
    1 row created.
    SQL> /
    1 row created.
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    X
    1
    2
    3
    4

  • Strange display of a long sequence of numbers - Should I press OK ?

    From type to time my iphone displays a long sequence of numbers and waits for me to press a green "OK" button. For example last sequence starts with 1259752976 1 199.664277......
    Anybody knows what's going on ?

    Yolanda,
    Yolanda Arroyo wrote:
    Hi folks,
    I have problems with my Tuxedo cofiguration using domains.
    I have Tuxedo8 installed in Linux 7.1. It connects to an Oracle 8.1.7 database,
    and has 2 domains cofigured to connect to a remote domain. (this domain is in
    fact WebLogic Server 6.1 running in the same machine)
    If I run this configuration, the servers in LDOM2 (for example, server1) are not
    able to connect to the database (this group don't include a TMS because is
    associated with the domain, and I cannot put an OPENINFO information in that
    group, for the same reason)
    BUT!!!! the most amazing thing is that, if I make no changes in the bdmconfig
    file, and in the UBBCONFIG I change the group WTC2 for a group that contains a
    TMS, in this way:
    I think that you are confusing the purpose of the 2 config files, ubbconfig and
    dmconfig.
    You should configure you application servers in the ubbconfig file. They
    should be in server groups configured with the correct TMS servers, OPENINFO, etc.
    One you have done this, you have a single domain.
    To extend this to talk to external domains, now you need to configure the gateways.
    Add a new server group to your ubbconfig and configure the domain gateway
    processes (GWADM, DMADM, GWTDOMAIN) in it. This group does not need a TMS (TMS
    services are provided by the domain gateway) or any OPENINFO.
    Now, write a dmconfig file. This does not reference any servers it does
    reference services that you want to import from other domains, or export to them.
    I hope this explains how you can successfully get your configuration working...
    Regards,
    Peter.

  • How to insert a sequence into a main production

    I am making a production with many sequences.  What is the bext way to insert a sequence into the main production?  I see that I can nest the secondary sequence, but I don't see any way to undo that in the event I want to make changes.
    Thank you for any help.

    Assuming you are on CC:
    Drag the sequence from the Project Window into the main timeline.
    For induvidual clips uncheck this button.

  • Cryptic sequence of numbers as sender name for invitations

    When I want to send an calendar invitation to my business address, my sender name is a cryptic sequence of numbers instead of "first name last name". These are the steps:
    1. Receiving Email form my iPad with the invitation
    2. Download the attached ics to my desktop of the windows PC
    3. Drag&Drop the ics to the Lotus Notes Calendar
    4. The invitation is visible, the sender name is i.e. 2fjfu3oodsjdf90499fj993efj0ßßejfefjß39eß939hgsdlfnasdäfa9e9
    I know that this invitation is from my private account. But what about friends I wanted to invite? Or should I invite only friends with apple equipment?!?! ;-)

    Well,
    Nokia MfE doesn't reply to my mails. I guess that only poeple using MfE v 2.09.158 who are not registered to the MfE Service (I guess you have to pay a monthly fee as it is with the Blackberry service) have the sender name problem. Of course you can use MfE with other mail providers than Nokia MfE. But in this case "Mail for Exchange" will appear as sender name.
    I now switched over to MfE's competitor "RS" and don't have this annoying problem anymore. The alternative to RS would be using the old MfE version where I didn't have that sender name prob. But as my battery was empty after 15 hrs using the old MfE version (with RS my battery lasts 3 days !!!) there is no real alternative to RS!
    This sender name problem seems to be part of Nokia's business strategy. As they want to compete with Blackberry they want you to register (and pay the MfE mail service monthly). Probably that's the reason why you get MfE for free (RS costs 50 US$).
     Any comments on my theory?!
    BR, Johnny

  • Trouble with SEQUENCE, loosing numbers

    Hi all, I use a sequence to generate the number of an invoice like this:
    Insert into table
    values(owner.sequence_name.nextval);
    But, if an error occurs this number get lost because of the way the sequence works, how can I avoid this??, there is another way to do it??? It doesnt matter if that solution doesn't use the sequence, but my design cannot accept numbers like 1,3,4,5,7, it has to be 1,2,3,4,5,6,7....
    Leo
    null

    Unfortunately, this is another one of those concepts that sounds simple but isn't.
    Yours is not an Oracle (or any other DB) problem; it is a design problem.
    The reason that none of the suggested alternatives solve your problem is that there are undefined elements in your requirements.
    There are actually two aspects to your of problem: 1) generating unique sequential numbers and 2) using those numbers.
    I would suggest starting over and try to clearly define the problem and the requirements.
    For example your stated requirements appear to be something like:
    1. Invoice numbers must to be unique
    2. Invoice numbers must be numeric
    3. The first invoice number must be 27 (modify per your requirements)
    4. Each new invoice must be numbered one higher than the previous invoice.
    5. Invoice numbers must be sequential with no missing numbers.
    While the above list seems to be complete there are some very important questions that are not yet answered.
    1. When does an invoice become an invoice? That is, when is the invoice number assigned? Is the number assigned before or after the invoice record is committed to the database? If the number is assigned before committing (e.g. when the user begins processing an invoice) but the invoice is then abandoned and never committed there will be a gap in invoice numbers.
    2. Can invoice records ever be deleted? If a committed record is deleted there will be a gap in the numbers. Some systems handle deletions by either flagging the records as deleted without actually deleting them or moving the records to a deleted table so that all invoice numbers are always accounted for.
    Check printing applications used to print on pre-numbered check forms. The line printers that were used had sprockets to feed the checks and the first check could not be printed on since the sprockets were above the print head. The operator would enter the first check number into the system and the application created a check record marked VOID for that check number. This ensured that all pre-printed checks were accounted for and had not been misplaced or stolen.
    Oracle's sequence generator can generate sequence numbers in sequential order and ensure that there are no gaps in the generation process.
    Oracle cannot ensure that your application uses those numbers in a way that avoids gaps.
    Even a normal INSERT trigger that might be used to get the next sequence value cannot be certain that the record it is inserting will actually be committed unless the COMMIT operation is performed within the trigger.
    Sorry to 'rain on your parade' but withouth a better problem definition we can't give you a better solution.

  • How do i insert a row into Numbers

    I'm new to numbers - how do i insert a row into a spreadsheet please?  The spreadshet started life in excel and was imported and saved as numbers.  I did try the help option but didn't seem to get the answer.

    right click on the row tab then select the "Add Row Above" or "Add Row Below"

  • How do I insert a row in Numbers?

    I see no function for the insertion of a row or column available.  Is it even possible?

    "There's a side tab to the box when you click on it.  I'm very new."
    It's called the Row Reference Tab for that row.
    Here are two other ways to insert a row into a Numbers table:
    Click any cell to select it. Go Table (menu) > Insert Row Above toinsert a row above the selected cell, or Go Table > Insert Row Below to insert a row below the selected cell.
    Click any cell to select it. Press option-up arrow OR option-down arrow to insert a row above or below the selected cell.
    To insert multiple rows, use a variation of the first method:
          Select a column of as many cells as you wish to add rows. Go Table > Insert Rows Above (or Below).
    I'll second Jerry's remarks regarding the Numbers '09 User Guide.
    Regards,
    Barry

  • How to create an action to insert hundreds of different numbers for limited edition prints?

    Hi,
    I sell limited edition prints of a run of between 350 and 500.
    I am trying to get it set up so that my signature and the print number is included as part of the print. Here is an example:
    You'll see at bottom left there is my signature and underneath is is the print number e.g. 110/350 (this is legible when printed at 18x12" size).
    Inserting the signature and the "/350" is easy since it only needs to be done once per image.
    The difficulty comes with inserting the actual print number e.g. "110"
    At the moment I have 0 to 9 written out and scanned in as separate numbers. So to make "110" I use the "1" digit twice, plus the "0" digit. I.e. I haven't written out 1 to 500 and scanned them in all as separate numbers, I've just done the 10 digits and use those 10 digits to make all the different numbers I need.
    Is there a way to create an action that will create say 350 JPEG copies of the original file, each one with its own unique print number inserted? (And ideally automatically saved with the print number as its file name!)
    Many thanks in advance

    This Script might be able to do some of what you wanted (the startNumber and endNumber would have to be set in the Script).
    It needs a Layer Group named »numbers« to contain layers for the numbers named »0«, »1«, …
    (script edited)
    // this script saves jpg copies with numbers created from number-layers in a layer group;
    // use it at your own risk;
    #target photoshop;
    if (app.documents.length > 0) {
    // define the numbers to create;
    var startNumber = 290;
    var endNumber = 310;
    // set to pixels;
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    // get doc;
    var myDocument = app.activeDocument;
    // getting the name and location;
    var docName = myDocument.name;
    var baseName = docName.match(/(.*)\.[^\.]+$/)[1];
    //getting the location;
    var docPath = myDocument.path;
    // duplicate the image;
    var thecopy = myDocument.duplicate (thecopy, false);
    // jpg options;
    var jpgopts = new JPEGSaveOptions();
    jpgopts.embedProfile = true;
    jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgopts.matte = MatteType.NONE;
    jpgopts.quality = 9;
    // get number layers;
    var numberSet = thecopy.layers.getByName("numbers");
    // collect in an array;
    var theNumbers = [numberSet.layers.getByName("0"), numberSet.layers.getByName("1"), numberSet.layers.getByName("2"),
    numberSet.layers.getByName("3"), numberSet.layers.getByName("4"), numberSet.layers.getByName("5"),
    numberSet.layers.getByName("6"), numberSet.layers.getByName("7"), numberSet.layers.getByName("8"), numberSet.layers.getByName("9")];
    numberSet.visible = true;
    // proceed if all numbers have been found;
    if (theNumbers.length == 10) {
    // hide layers;
    for (var n = 0; n < numberSet.layers.length; n++) {
    numberSet.layers[n].visible = false
    var theState = thecopy.activeHistoryState;
    // process the numbers;
    for (var m = startNumber; m < endNumber + 1; m++) {
    // the position;
    var theHor = 500;
    // create an array for the new numbers;
    var theArray = new Array;
    // the number;
    var thisString = String(m);
    // duplicate layers to create the numbers;
    for (var o = 0; o < thisString.length; o++) {
    var theNumberLayer = theNumbers[Number(thisString[o])];
    // create copy;
    var theLayer = duplicateMoveRotateScale (theNumberLayer, theHor - Number(theNumberLayer.bounds[0]), 0, 100, 100, 0);
    theNumberLayer.visible = false;
    //alert (m+"_"+o+"\n"+theNumberLayer+"\n"+theLayer);
    // set the hor to edge of the new layer;
    var theHor = theLayer.bounds[2];
    theArray.push(theLayer);
    // get the number for the file name;
    var theNumber = bufferNumberWithZeros(m, String(endNumber).length);
    //save jpg;
    thecopy.saveAs((new File(docPath+"/"+baseName+"_"+theNumber+".jpg")),jpgopts,true);
    // remove copied layers;
    //for (var p = theArray.length - 1; p >= 0; p--) {theArray[p].remove()};
    thecopy.activeHistoryState = theState;
    // close copy;
    thecopy.close(SaveOptions.DONOTSAVECHANGES);
    // reset ruler;
    app.preferences.rulerUnits = originalRulerUnits
    //that’s it; thanks to xbytor;
    ////// buffer number with zeros //////
    function bufferNumberWithZeros (number, places) {
              var theNumberString = String(number);
              for (var o = 0; o < (places - String(number).length); o++) {
                        theNumberString = String("0" + theNumberString)
              return theNumberString
    ////// duplicate layer and move, rotate and scale it //////
    function duplicateMoveRotateScale (theLayer, theX, theY, theScaleX, theScaleY, theRotation) {
    app.activeDocument.activeLayer = theLayer;
    try{
    // =======================================================
    var idTrnf = charIDToTypeID( "Trnf" );
        var desc10 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref6 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref6.putEnumerated( idLyr, idOrdn, idTrgt );
        desc10.putReference( idnull, ref6 );
        var idFTcs = charIDToTypeID( "FTcs" );
        var idQCSt = charIDToTypeID( "QCSt" );
        var idQcsa = charIDToTypeID( "Qcsa" );
        desc10.putEnumerated( idFTcs, idQCSt, idQcsa );
        var idOfst = charIDToTypeID( "Ofst" );
            var desc11 = new ActionDescriptor();
            var idHrzn = charIDToTypeID( "Hrzn" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc11.putUnitDouble( idHrzn, idPxl, theX );
            var idVrtc = charIDToTypeID( "Vrtc" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc11.putUnitDouble( idVrtc, idPxl, theY );
        var idOfst = charIDToTypeID( "Ofst" );
        desc10.putObject( idOfst, idOfst, desc11 );
        var idWdth = charIDToTypeID( "Wdth" );
        var idPrc = charIDToTypeID( "#Prc" );
        desc10.putUnitDouble( idWdth, idPrc, theScaleX );
        var idHght = charIDToTypeID( "Hght" );
        var idPrc = charIDToTypeID( "#Prc" );
        desc10.putUnitDouble( idHght, idPrc, theScaleY );
        var idAngl = charIDToTypeID( "Angl" );
        var idAng = charIDToTypeID( "#Ang" );
        desc10.putUnitDouble( idAngl, idAng, theRotation );
        var idIntr = charIDToTypeID( "Intr" );
        var idIntp = charIDToTypeID( "Intp" );
        var idbicubicAutomatic = stringIDToTypeID( "bicubicAutomatic" );
        desc10.putEnumerated( idIntr, idIntp, idbicubicAutomatic );
        var idCpy = charIDToTypeID( "Cpy " );
        desc10.putBoolean( idCpy, true );
    executeAction( idTrnf, desc10, DialogModes.NO );
    return app.activeDocument.activeLayer
    } catch (e) {}
    Edit: This Script just uses the layers’ horizontal bounds for orientation, so it does not address the issue I referred to earlier reagrding aesthetically pleasing spacing of the elements.

  • Comparing a sequence of numbers

    Morning Everyone,
    I have a little challenge on board and would like to have some ideas about how to proceed with it.
    As you all are aware of the Lotto game. u have to choose 6 numbers out of 40. There are exactly 3,838,380 combinations that can be played.
    these combinations can be generated and stored in a table.
    Now lets say i have 1000's people playing and i would like to find a way to know how many combinations are repeating and also what combinations have not been played.
    How can i do that?
    Kind Regards
    Kevin

    Billy Verreynne wrote :
    The universe does not keep a scoreboardWell, actually, you cannot prove that. Maybe it does...
    :D
    To the OP.
    I think you can generate the table containing all possible combination using the following query (assuming that you cannot chose the same number twice) : with b as (select level n from dual connect by level <=40)
    select count(*)
    from (
    select
    b1.n,
    b2.n,
    b3.n,
    b4.n,
    b5.n,
    b6.n
    from b b1, b b2, b b3, b b4, b b5, b b6
    where
    b6.n>b5.n
    and b5.n>b4.n
    and b4.n>b3.n
    and b3.n>b2.n
    and b2.n>b1.n
    /I just ran the count(*) on the query and it brings me 3838380 rows, as expected.
    the query gives each row with the 6 different values in ascending order (1st column being < than 2nd, being < than 3rd, and so on).
    If you want to compare with played combination, you should make sure you store those combination the same ways (col1 < col2 < col3 ...) using a constraint on the table.
    SQL> create table possible_combinations (
      2  c1 integer not null,
      3  c2 integer not null,
      4  c3 integer not null,
      5  c4 integer not null,
      6  c5 integer not null,
      7  c6 integer not null,
      8  primary key (c1,c2,c3,c4,c5,c6)
      9  );
    Table created.
    SQL> alter table possible_combinations add constraint asc_ordered check (c6>c5 and c5>c4 and c4>c3 and c3>c2 and c2>c1);
    Table altered.
    SQL> insert into possible_combinations
      2  with b as (select level n from dual connect by level <=40)
      3  select
      4  b1.n,
      5  b2.n,
      6  b3.n,
      7  b4.n,
      8  b5.n,
      9  b6.n
    10  from b b1, b b2, b b3, b b4, b b5, b b6
    11  where
    12  b6.n>b5.n
    13  and b5.n>b4.n
    14  and b4.n>b3.n
    15  and b3.n>b2.n
    16* and b2.n>b1.n;you can then create another table that store the played combinations :
    SQL> create table played_combinations(
      2  userid integer not null,
      3  dateplay date not null,
      4  c1 integer not null,
      5  c2 integer not null,
      6  c3 integer not null,
      7  c4 integer not null,
      8  c5 integer not null,
      9  c6 integer not null);
    Table created.
    SQL> alter table played_combinations add constraint playordered check (c6>c5 and c5>c4 and c4>c3 and c3>c2 and c2>c1);
    Table altered.You can easily get :
    - the number of time a combination was played :select c1, c2, c3, c4, c5, c6,
    count(*) Nbr_of_time_played,
    trunc(100*count(*)/(select count(*) from played_combinations),3) pct_of_played
    from played_combinations
    group by c1, c2, c3, c4, c5, c6
    order by count(*) desc;-the list of combinations that were never played :select t.c1, t.c2, t.c3, t.c4, t.c5, t.c6
    from possible_combinations t
    where not exists (select null
    from played_combinations p
    where t.c1=p.c1
    and t.c2=p.c2
    and t.c3=p.c3
    and t.c4=p.c4
    and t.c5=p.c5
    and t.c6=p.c6
    );

  • Generating a sequence of numbers

    Hi there, I'm trying to generate a number sequence. The description is as follows:
    a)1 is in the sequence
    b) If number X is in the sequence then so are the numbers 3*X, 5*X, and 7*X.
    c) No number appears more than once in the sequence, and
    d) No other number is in the sequence.
    Thus, first few numbers in the sequence are:
    1,3,5,7,9,15,21,25,27,35,45,49,63,75,81,105...
    I need to print out the first 1000 elements of this sequence which is fairly large.
    How can i compute this sequence and print the first 1000 elements of this sequence? I think that we need 3 separate methods, 1 for 3*X, 5*X and 7*X. Can anyone out there help me with this?

    The following code is in ML (because that's what I did this in for an exercise in my first year). datatype stream = Item of int * (unit->stream);
    fun cons (x,xs) = Item (x,xs);
    fun head (Item(i,xf))=i;
    fun tail (Item(i,xf))=xf();
    fun maps f xs = cons(f (head xs), fn()=> maps f (tail xs));
    fun merge (xs,ys)=
        let val x = head (xs);
            val y = head (ys)
        in if x=y then cons(x, fn()=>merge((tail(xs)), (tail (ys))) )
           else if x<y then cons(x, fn()=>merge((tail(xs)), ys) )
                else cons(y, fn()=>merge(xs,(tail(ys))) ) end; (* y<x *)
    fun merge3(xs,ys,zs) = merge(xs,merge(ys,zs));
    fun threefiveseven()=
        cons(1, fn()=>
             merge3( maps (fn x=> 3*x) (threefiveseven()),
                     maps (fn x=> 5*x) (threefiveseven()),
                     maps (fn x=> 7*x) (threefiveseven()) )); Translating into Java elegantly isn't easy, because Java doesn't have function pointers. It took me quite a while, because it's difficult to avoid infinite recursion. (That's what the unit->stream and fn()=> is all about). Here you go: abstract class Function
        abstract int f(int i);
    class Maps extends Stream
        Function f;
        Maps(Function f, Stream xs)
            this.head = f.f(xs.head());
            this.tail = xs;
            this.f = f;
        Stream tail()
            return new Maps(f, tail.tail());
    class Merge extends Stream
        Stream xs;
        boolean tailxs;
        Stream ys;
        boolean tailys;
        Merge(Stream xs, Stream ys)
            int x = xs.head();
            int y = ys.head();
            this.xs = xs;
            this.ys = ys;
            if (x == y)
                head = x;
                tailxs = true;
                tailys = true;
            else if (x < y)
                head = x;
                tailxs = true;
                tailys = false;
            else
                head = y;
                tailxs = false;
                tailys = true;
        Stream tail()
            Stream left = (tailxs) ? xs.tail() : xs;
            Stream right = (tailys) ? ys.tail() : ys;
            return new Merge(left, right);
    abstract class Stream
        int head;
        int head() { return head; }
        Stream tail;
        abstract Stream tail();
    public class Test
        public static void main(String[] args)
            printFirst(new ThreeFiveSeven(), 10);
        static void printFirst(Stream stream, int n)
            while(n-- > 0)
                System.out.println(stream.head());
                stream = stream.tail();
    class ThreeFiveSeven extends Stream
        ThreeFiveSeven()
            head = 1;
        Stream tail()
            Stream three = new Maps(new Times3(), new ThreeFiveSeven());
            Stream five = new Maps(new Times5(), new ThreeFiveSeven());
            Stream seven = new Maps(new Times7(), new ThreeFiveSeven());
            return new Merge(three, new Merge(five, seven));
    class Times3 extends Function
        int f(int i) { return 3 * i; }
    class Times5 extends Function
        int f(int i) { return 5 * i; }
    class Times7 extends Function
        int f(int i) { return 7 * i; }
    }

  • Database Adapter: Insert, relationships, sequences and problems of course

    Hello Everyone!!
    I'm trying to do an insert in an Oracle Express Database with a database adapter. I'm trying to do the insert in two tables: SOLICITUDES with a column called NUMSOLICITUD that is also the primary key of the table and it's populated from its own sequence and the other table whose name is DOCJUST with a field NUMSOL. SOLICITUDES has a 1:M relationship with DOCJUST and the fields used in this relationship are NUMSOLICITUD and NUMSOL. The problem is that when the adapter do the insert, the first insert made on SOLICITUDES is correct, but when it tries to insert in the DOCJUST table, when it's supposed to insert in NUMSOL the same value inserted in NUMSOLICITUDES instead of that, a NULL value is inserted in NUMSOL so the process fails. Is it because the NUMSOLICITUDES column is populated from a sequence? How can I resolve that?
    Thanks!!

    Hi,
    OK, I found the following article: http://soa-bpel-esb.blogspot.com/2010/04/understanding-catch-and-catchall.html
    Using the info from that article I have created a test flow, which contains the same insert database adapter as the production flow. I have placed the Invoke within its own scope and attached a "CatchAll" block to this scope. To this block I have added a "empty" step (do nothing).
    In my tests, I see the desired results i.e. the second time I initiate the flow with the same data, the CatchAll block executes, which does nothing, and processing continues after the scope.
    So far so good - my query is how would I catch the specific error of unique index violation rather than general catchall?
    As before, and assistance/comments greatly appreciated.
    Anit

  • Insert new sequence (project) into an existing project?

    For a slide show mixing stills and video over songs:
    Project was "finished," with images arranged and sequeing as I wanted, and matched to three songs. Including credits, all nicely wrapped up.
    I now have to add more images and 1 new song. *This new sequence+song needs to insert between the current songs 2 and 3, maintaining all existing footage and audio as is.* (In other words, song/sequence 3 will still be the final sequence.)
    What is the best way to go about this?
    1) Create a separate Project B, and then insert that as a whole video+audio sequence into current Project A? Is that even possible?
    2) Insert the new audio track where it will live and begin assembling images against it?
    3) Insert and assemble the new images and then add the audio?
    4) Some other way?
    A related query: when adding new audio, it goes in as one large green b.g to the images. On my current project, each audio track is a simple line underneath the images. This latter way is much easier to deal with. How can I make that happen?
    Thanks much.
    Jonathan

    Add your new images first. Then drag the new audio track and drop it on the first of the new images.

  • Problem inserting auto-sequence for PK value using trigger - ORA-02287

    I have a query where the sub-query is working. I created a table to receive the results of the query. I created a Sequence:
    CREATE SEQUENCE SEQ_RPT_H2_LOOPS
    MINVALUE 1
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;
    Then I created a trigger:
    CREATE OR REPLACE TRIGGER TRG_RPT_H2_LOOPS
    BEFORE INSERT ON RPT_H2_LOOPS
    FOR EACH ROW
    BEGIN
    SELECT SEQ_RPT_H2_LOOPS.NEXTVAL INTO :NEW.RECORD_ID FROM DUAL;
    END;
    And here is the Insert query.
    accept month_year;
    accept prior_month_year;
    insert into rpt_h2_loops (
         RECORD_ID,
         MKT_CODE,
         MKT_NAME,
         ECCKT,
         VENDOR_ID,
         ECCKT_VENDOR_ID,
         OCN,
         FAC_TYP,
         ALOC,
         ZLOC,
         STATE,
         OCN_STATE,
         OCN_STATE_COLO,
         SRVC_TYP,
         CUR_PERIOD,
         PRIOR_PERIOD,
         TIME_STAMP )
    select seq_rpt_h2_loops.nextval
    ,substr(r.sub_acct,4,3)
    ,m.market
    ,rr.ckt
    ,rr.vendor_id
    ,rr.ckt||rr.vendor_id
    ,rr.ocn
    ,rr.srvc_typ
    ,'N/A'
    ,rr.zloc
    ,rr.st_cd
    ,rr.ocn||rr.st_cd
    ,rr.ocn||rr.st_cd||rr.zloc
    ,rr.srvc_typ
    ,'&month_year'
    ,'&prior_month_year'
    ,sysdate
    from rco.rate_route rr
    ,rco.cogs_resource r
    ,rco.cogs_mkt m
    where rr.cvbi_key = r.cvbi_key
    and     m.subacct = r.sub_acct
    and     to_char(rr.period, 'mm/yyyy') = '&month_year'
    and     to_char(r.period, 'mm/yyyy') = '&month_year'
    and     rr.srvc_typ = 'CUNE'
    group by    substr(r.sub_acct,4,3)
    ,m.market
    ,rr.ckt
    ,rr.vendor_id
    ,rr.ckt||rr.vendor_id
    ,rr.ocn
    ,rr.srvc_typ
    ,rr.zloc
    ,rr.st_cd
    ,rr.ocn||rr.st_cd
    ,rr.ocn||rr.st_cd||rr.zloc
    );The problem is that I am getting a ORA-02287: sequence number not allowed here on the NEXTVAL keyword.
    The sequence and trigger compiled without problem. I just can't seem to insert that value into the query. Any help would be appreciated.

    you are defeating the purpose of trigger which is before insert so just rewrite the query and remove the column for which value will be inserted using the created sequence and your code will work.
    Regards,
    Vikas Kumar

  • Find gaps in sequence of numbers

    Hi,
    I'm trying to scan through multiple records containing millions of numbers. What I need to do is to print out the numbers that are sequential as such:
    If the record contains a sequence like this:
    46859995600
    46859995699
    And there is no breakage in that sequence, then print:
    46859995600 100
    If that sequence is broken somewhere, then print series of 10 that are sequential, f.e:
    46859995600 10
    46859995620 10
    46859995630 10
    I already have a bash script for this, but it's way too slow. If anyone can help me out I'd be very grateful, perhaps a "awk" solution.
    Thanks!

    Indeed.  Also, note that the code above makes several assumptions: 1) monotonicity ... but "sort" can take care of that; 2) there is no zero.  This would be easy to fix, but in the first draft I didn't bother with it: 000-009 will not currently be counted; 3) the application is not mission critical; 4) there are no blank line; 5) each line contains *only* the number.
    On #3, my code may be faster, but it hasn't been checked for accuracy.  Be sure to test for accuracy before trusting its output.  In fact, I just tested it ... it failed.
    I tested it after I recoded it in C.  The speed went from 2min 3sec to 0.39sec ... that's nice.  But the results file was *much* smaller.
    The results from the bash version includes several duplicates, and some erroneous inclusions.  Given that so far the C version seems more accurate (but still needs testing) and *much* faster, I'd go with patching this up further:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    unsigned long lt = 0, lh = 0;
    unsigned long n, prev = 0, tens[10];
    int nten=0;
    void check_tens() {
    int i;
    if (lh) printf("%lu 100\n",lh);
    else for (i = 0; i < 10 && tens[i]; i++)
    printf("%lu 10\n",tens[i]);
    memset(tens,0,10*sizeof(unsigned long));
    nten = 0;
    int main() {
    int i;
    memset(tens,0,10*sizeof(unsigned long));
    while (fscanf(stdin,"%lu\n",&n) == 1) {
    if ((n % 10) == 0) lt = n;
    else if ((n % 10) == 9) {
    if (!lt || n - 9 == lt) tens[nten++] = lt;
    lt = 0;
    if ((n % 100) == 0) lh = n;
    else if ((n % 100) == 99) check_tens();
    if (n - prev != 1) {
    lt = lh = 0;
    for (i = prev; i < n; i++)
    if ((i % 100) == 99) { check_tens(); break; }
    if ((n % 10) == 0) lt = n;
    if ((n % 100) == 0) lh = n;
    prev=n;
    lh = 0;
    check_tens();
    return 0;
    EDIT: I can actually confirm the C version is not yet accurate.  ARGH!
    Last edited by Trilby (2014-05-02 00:11:09)

Maybe you are looking for