[ADF, JDev12.1.3] How to set the value of an attribute of VO 'max (attribute) + 1' when creating a new record?

Hallo,

I have a VO that selects records from a table databace where FkId = < value >.

For example: this is the database table...

ID RowDetNumber OtherFields FkId

1   3     1            ...

2   3     2            ...

3   3     3            ...

4   3     4            ...

5   4     1            ...         |

6   4     2            ...         | -VO selects these records (where FkId = 4 for example)

7   4     3            ...         |

8   5     1            ...

9   5     2            ...

When a new record is created the field RowDetNumber must be calculated with the logic of the max (RowDetNumber) + 1.

So for the example above, the calculated value should be 3 + 1 = 4.

I would like to know how I can calculate the value and assign to the RowDetNumber attribute.

I did some experiments using a Groovy expression as a default value for the field, but I got only errors.

I'm a bit confused on how I can do so a few details / examples / tips are welcome

In particular, a small example for every possible approach would be happy.

Thank you

Federico

Federico, the solution mentioned in the block will work as it only generates unique numbers without guarantee that the generated numbers are without flaw. However, if you want to use max + 1 this normally means you want to have a sequence without gap. It is very very complicated in nature. It doesn't matter what application you're trying, there is almost always room for error, ending with duplicate numbers.

The trigger also works as the DB supports triggers on MS SQL.

If you don't need a number of gap-less for the attribute, you can use the groovy solution and just get a number of a sequence is is guaranteed unique and greater value, like the last number that you asked of the sequence. In this way, you can have the sorted records

ID RowDetNumber OtherFields FkId

1  3    1            ...

2  3    7            ...

3  3    9            ...

4  3    10            ...

5  4    3            ...        |

6  4    5            ...        | -VO selects these records (where FkId = 4 for example)

7  4    12            ...        |

8  5    4            ...

9  5    6            ...

Timo

Tags: Java

Similar Questions

  • [ADF, JDev12.1.3] How to pass tha value of an attribute of the VO at the request of a field of the VO even LOV?

    Hallo,

    I have a LOV associated FieldB and showed it in the popup LOV, these must be filtered according to the value of FieldA (2 fields belongs to the same TableVO VO).

    The LOV associated FieldB is based on a VO that has a binding variable 'BindCodInstitute '.

    I would like to know how I can assign the vuale of FieldA to the variable binding.

    What expression I have co-debtors variable binding?

    Thank you

    Federico

    also see - https://blogs.oracle.com/aramamoo/entry/how_to_create_multi_level

  • How to set the value of an attribute of a button?

    Dear all,

    use developer j 11.1.1.1.3 and I have a master page detail, now I need the user when press the button create - insert on detail to copy a value from the master in an attribute on the details... I added listener set action on the Insert button and on the "of:" I wrote the main attribute binding but did not know what to write on the "to:" field... I tried row.bindings.detail_column_input_value but did not work on the common language runtime, it gave me this message
    -> the input string for the "detail_column_name".


    Best regards
    Lama

    Have you tried using the integrated operation 'Create with parameters' instead of 'CreateInsert '?
    In this way, you will be able to create a new line and set the default values.

    Kristjan

  • How get/set the value of the DataObject object in the task of the API?

    How get/set the value of the DataObject object in the task of the API?

    Are there examples of code availible?

    Hello

    You are here: http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_worklistcust.htm

    Antonis

  • How to set the value of QUERY using PL/SQL process?

    Hello

    I use APEX 4.2...
    How to set the value of the REQUEST using process of PL/SQL which lies before the header - where the value of the REQUEST should appear on the URL?

    Kind regards
    Fateh

    You cannot set a value of demand in a PL/SQL block. You can run a PL/SQL block on a request which is the id of a button for example.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Apress.com/9781430235125
    http://Apex.Oracle.com/pls/Apex/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

  • How to set the value of something in a component of the main application?

    Hello

    Maybe I've worked on it too long, but I can't understand how to set the value of the text property of a text entry field in my main application component in a block of mx:Script. I have a component called Login in the components folder, and I need to set the text value of empNum. In my statement of mxml up there, I said these components such as xmlns = "components.*" so, logically, the property, I'm putting a c.Login.empNum.text. I can't understand the correct syntax to make this work, and I've tried everything I can think of. Does anyone have any suggestions? I think this should be easy, and there is just something missing me.

    Thank you!
    Holli

    Have you tried to give him an id?

    If later you can make the loginScreen. empNum.text = "my text".

    Laurent,

  • How to set the value of a field from the LOV of another field.

    I'm trying to figure out how to set the value of a field (P_PROGRAM) to the value of another field of based lov (P_STATE).

    The P_PROGRAM field is a hidden field. The P_STATE field is a required field and is based on a list of values for the State Codes.

    When a user selects the State to P_STATE, the field of the P_PROGRAM should be set to this value, as well.

    I tried different ways to get there via a function call on the post for the calculation of the field P_STATE, defining the source P_PROGRAM to the value of the page item P_STATE put varialbles, creating a process before SENDING, and they all still come back as having a NULL value for P_PROGRAM, therefore impossible to create the file in the db as the PROGRAM is a mandatory field in the table.

    Can you please help? Thank you, Laura

    Laura,

    It is always helpful if you provide information about the Apex version you are using. The Apex 4 you can use Dynamic Actions to achieve this. In earlier versions is possible using processes to submit or javacsripts, as well.

    Heres how you do in 3.x with treatment to submit, to make it work in 4.0 as well.

    1 do the P_STATE ' select list submits the Page.
    2. Add a calculation on the point P_PROGRAM, or write to him assign a value based on a process. The treatment should be OnLoad after the header
    3. If the page does not have an unconditional branch that loops on itself, add a. NOTE: The direction must be the last branch (larger sequence number) and should have checked "Save Session State".

    This is what will happen
    a. when the State is selected Page will be submitted
    (b) it will take the unconditional branch to himself and save the value of P_STATE
    c. the calculation process / fills the value of the P_PROGRAM element when the page reloads

    Kind regards

  • Can declaratively set the value of some attributes depend on an attribute in a row of VO?

    Hi, experts.

    In jdev 11.1.2.3,.

    Can declaratively set the value of some attributes depend on an attribute in a row of VO?

    For example, there is a VO (id, salt boolean, integer status, entire IsValid), how to set status=-1,IsValid=-1 when salt is checked (selected)?

    I tried:

    Method A:

    1 set the status depends on saltand the default attribute value:

    If (salt is true)

    Returns - 1

    on the other

    {

    If (salt is false)

    Returns 0

    on the other

    Returns a null value

    }

    2. set IsValid dependent statusand attributes by default as: status.

    3. set all of these three attributes can be changed to always.

    If the parameter above may work, then apparently it's much simpler to write Java code.

    Unfortunately, he is unable to work the way you want.

    There is some complex another declaratively to do:

    Method B:

    1. create a selVO (id, booleanValue1 boolean, integer numberValue1, string stringValue1) with static values:

    (1, false, 0, "" false for salt: not selected ' ");

    (2, true,-1, "" the true value of salt: selected ' ");

    2. put selVO as Data Source list for the list of the salt value and return values from the list:

    Salt-> booleanValue1,

    Status-> numberValue1,

    IsValid-> numberValue1.

    But this alternative way has a few weaks a fortiori more complex:

    Advice from the interface user of salt can not defined by default list Type "CheckBox".

    Cannot, therefore, method A feasible?


    Thank you!

    BAO

    Hello Bao,

    You can write THE Expression value of Field2

    #{bindings. Field1.inputValue == 'Y '? 1:-1}

    (Auto submit True on Field1

    Field1 Field2 on partial trigger)

    Also, you can write logic in VORowimpl Set accessor methods.

    Thank you

    Jeet

  • [ADF, JDev12.1.3] (How to set values for the attributes 1) to create a file and 2) committing to the database?

    Hallo,

    in my tables and forms (created from VO istances) there are some areas for which, insert and update, I calculate and set the value programmatically when a record is created or updated.

    In some cases, I put the necessary values using the 'CreateWithParams' in the workflow diagram...

    In some other ones, I associate an action, a bean, a created button drag-and - drop operation 'CreateWithParams' of the istance VO...

      public String cwpButton_action() {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("CreateWithParams");
        // here I calculate and set the needed params
        // ...
        Object result = operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
          return null;
        }
        return null;
      }
    

    And is ok if I can calculate the values for the attributes before a new record is created.

    But the approach that I have used to define the attributes (for new and updated records) whose value should be caluclated after the user has filled in the fields, before committing to the database?

    Thank you

    Federico

    Federico,

    Let me first tell you that our code is activity masking errors (the cache instead of working on them).

    1. If (! operationBinding.getErrors () .isEmpty ()) {}
    2. Returns a null value.
    3. }
    4. Returns a null value.

    This means that you do not check the errors at all. You must at least print a log with the error message, you receive, if you get one!

    To solve your problem, you override the method prepareForDML() of the entity or entities in question. You can calculate and set the necessary attributes until they get engaged in the doDML(). Do not use doDML() because it is too late in the life cycle.

    Timo

  • [ADF, JDev12.1.3] How to get the column headers, request of VO and VO bind vars used by an af:table?

    Hallo,

    I want to create a method that takes as a parameter the id of an af:table (used to display the search results) and returns:

    • the column headings of the af: table
    • Visible property (true/false) of the columns af:table
    • the actual query of the VO instance used to create the af: table
    • the values of real bind variables passed to the query of the instance of VO

    I would like to create a servlet which takes the parameters reruns the query and returns a report Excel/PDF file that contains exactly the same columns and same of the af records: table.

    I'm a little confused on who use the code to achieve this... you kindly help me?

    I did a similar qustion here Re: [ADF, JDev12.1.3] how to export an af:table to Excel in an ADF Essentials application? but then I guessed that it was preferable to create a new thread.

    Thank you

    Federico

    For this, you can use this type of code

    Context LocaleContext = _adfTableBinding.getLocaleContext ();

    for (attr AttributeDef: attributeDef) {}

    Label As String = attr.getUIHelper () .getLabel (context);

    _logger.info ("Attritbute name:" + attr.getName () + "column name:" + attr.getColumnName () + "Col4Query name:" + attr.getColumnNameForQuery () +)

    "Name:"+ label);

    }

    which produces this output

    Timo

  • [ADF, JDev12.1.3] How to set a variable to bind a VO (where clause) in a managed bean?

    Hallo,

    I have a request based on VO.

    The query contains a where clause clause and a bindi variable.

    In a managed bean I would like to access the iterator of VO setting the value of the bind variable and read the result.

    I found this code it is good start, but I do not know how to set the variable binding.

    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    DCIteratorBinding iter = (DCIteratorBinding ) bindings.get("MyVO1Iterator");
    iter.execute();
    
    
    

    You kindly help me?

    Also, I would like to know if it is generally advisable to use VO directly in controlled beans or whether it would be best to create in the AppModuleImpl methods that do this and return the result.

    In my case for example of the VO will return max 1 plug so I'm in doubt, if the creation of a method in the AM that returns a custom class, which attributes contain values of the line of VO.

    Sorry if these questions may seem artificial, but I am a beginner, I have many doubts and so I would be happy to receive some tips regarding best practices.

    Thank you

    Federico

    You can use:

    iter.getViewObject().setNamedWhereClauseParam("yourBindVar", value);
    

    Note that this approach is used if you have bind variable in the where clause.

    To set variables bind to ViewCriteria, you must use VarableValueManager.

    This post may be useful for you: binary: how to set the Bind variable values at run time?

    Also, I would like to know if it is generally advisable to use VO directly in controlled beans or whether it would be best to create in the AppModuleImpl methods that do this and return the result.

    You must set "use VO directly.

    For example, from the point of architecture, is probably best to use the method in the model project which will set the bind variable and execute the query.

    Or you can use the ExecuteWithParams operation in your the view layer.

    In my case for example of the VO will return max 1 plug so I'm in doubt, if the creation of a method in the AM that returns a custom class, which attributes contain values of the line of VO.

    Not to complicate your life

    All VO lines are represented as ViewRowImpl class if you already have "custom class".

    Finally, you can generate your own ViewRowImpl class if it is necessary for this.

    Dario

  • [ADF, JDev12.1.3] How to set attributes for new records in detail your (by program) in a panel of master / detail tabbed?

    Hallo,

    in a fragment that I have a tabs including the 1st tab panel contains an af:form (created from a master VO) while the other tabs each contain an af:table (created from a VO detail).

    When the fragment is used in design mode , I need to set some attributes (hidden) for each VO.

    I guess I can begin to insert before the fragment, in the workflow, the operation "Create with Params" for the master VO.

    But who should I set the values for the fields the other VO's hidden when the user create new records?

    Some fields of VO can be set taking values directly from session and pageFlow scope while the value must be calculated for other fields.

    Thank you

    Federico

    Retail vo was create with Potsdam too. You can use what you can do to master VO. link the button to detail to a bean and calculated method to set the parameters before running the createWithParam.

    Timo

  • How to set the value of a variable in automator?

    I'm totally new to automator I found a post that I try to reuse

    to Re: copy multiple files from TextEdit in one Word file

    I want to open a series of html files in a folder and convert in a TextEdit rtf file.

    However, I am unable to automator find out how set the value of a variable such that it appears in this post

    I looked at every command in library without a lot of fortune

    Any help?

    Thank you

    Dan

    Its in Utilities.

    In Automator, use the search box:

  • How to set the value of a variable in a cluster in LabVIEW to c#?

    Hi guys, I'm working on a small c# program, which by using the interface provided by LabVIEW.  And I know that, with the help of lv. SetControlValue (name, value) can set a variable just on the front panel. But in my case, there are several groups on the front panel. Then it confused me how to set the variables in these groups. For example, there is a cluster named clusterA and a variable named a., I tried something like this:

    lv.SetControlValue("clusterA.valueA",1);
    

    but it totally inoperable. Everyone has some experience with this sort of thing? Thank you very much!!

    Hey guys, thanks a lot for all your response. I just found a simple way to solve this problem. For example, there is a cluster named "ClusterA", and there are only two witnesses, who are: an int value named "IntA" (default = 10 IntA value) and a string value named "StringA" (by default the StringA = 'abc'). In c#, if you call the method:

    var clusterA is vi (Array). GetControlValue ("ClusterA");

    you will get a table looks like: clusterA = {10, 'abc'}; So if you want to change IntA 123, you simply do:

    clusterA.SetValue (123, 0); 123 the value, 0 is the index of IntA in clusterA, after this clusterA table = {123, 'abc'}

    After that, simply to make the table in LabVIEW using:

    VI. SetControlValue ("ClusterA", clusterA);

    and now you see the LabVIEW, IntA is changed.

  • How to set the value of adjecent record

    Hello

    For an interactive report, I wanted to know, how set the value for one of the value column taken recording (the visible record in the report) adjecent to the same column in the current record.    The reason behind this requirement is, the table contains cirtain ID which is populated based on cirtain condition.  And the same ID must be set to adjecent different records.  Since this is event based on human evaluation of the data, I can not run the UPDATE command in the background.

    To simplify the requirement, suppose, report IR on the employee.  Based on the user, click one of the dummy 'comlumn link', the value COMMISSION_PERCENT must be copied to the next record.  If I know EMPLOYEE_ID value of the next record, then update SQL will do the job.  But how?

    Thank you

    -Anand

    Hi Anand,

    Please check the sample application you gave, I created the same according to your requirement.

    Here are the steps that I did.

    1. edition your column that you use as a button.

    A class has been added to this button under link attributes

    class="uButton cpycomm" role="button"
    

    URL: javascript:void (0);

    2. edited Page attributes

    Under run when the Page loads

     $("a.cpycomm").click(function(){
        var $el = $(this);
        var nextemp = $el.closest("tr").next().find('td[headers="C725254625175515007"]').text();
        var comm = $el.closest("tr").find('td[headers="C725255480705515009"]').text();
        $("#P1_EMPNO").val(nextemp);
        $("#P1_COMM").val(comm);
    
        if (confirm('Copy Commission to next record ?')) {
           apex.submit('SAVE');
        }
      });
    

    3. a process page to update the commision has created.

    Kind regards

    Jitendra

Maybe you are looking for

  • Portege M300-101 - every 30 min I get a BSOD

    I have a Portege M300-101 (Windows XP) and every 30 minutes I comes up with a blue screen with a text about 1 sec so I can't read it, then restarts and happen in 30 minutes

  • How big a HARD drive can put you in a 3110CT

    I have updated the BIOS to 7.70 and want to know how big a HD that I can use to replace the 6 GB it it came with. Does anyone know what size the suppport of new will BIOS?

  • How to disassemble, repair and improve Toshiba laptops.

    I was looking for info on how to upgrade the HDD on my Satellite 1800 814 when I came across this site so thought that I post here for everyone. It seems to be exactly what I searched, and not only for the Satellite, but for other models as well. htt

  • Cannot start on my recovery DVDs

    Original title: I am currently trying to run win xp repair console, but am not able to boot from my DVD Rom eventhough my BIOS Setup is arranged for my pc to my DVD Rom first start My Windows XP takes a long time to load and when I get to the loading

  • Why my computer so much during a buffer film

    When I watch a movie, the buffers of the computer as long as it is not worth looking at...