locked
How can I change the "ADD" query? RRS feed

  • Question

  • I have a simple db table, with an ID column, type, and a Value column.

    If I add the default "Add..." function, when I hit that, it comes up with a screen where the ID is at 0.

    I'd like to update the query so for a given TYPE, it will get the next available ID value.

    So, if Type is "A", and there are "A" types already in the table that have id 101, 102, 103 -- then I want to ADD..., and have the screen display ID=104, type="A", and blank for the new value.

    WHERE/HOW do I edit the Add query (seems like any query edit in the screen customization is for the SELECT query).

    Monday, December 20, 2010 6:09 PM

Answers

  • I have a simple db table, with an ID column, type, and a Value column.

    If I add the default "Add..." function, when I hit that, it comes up with a screen where the ID is at 0.

    I'd like to update the query so for a given TYPE, it will get the next available ID value.

    So, if Type is "A", and there are "A" types already in the table that have id 101, 102, 103 -- then I want to ADD..., and have the screen display ID=104, type="A", and blank for the new value.

    WHERE/HOW do I edit the Add query (seems like any query edit in the screen customization is for the SELECT query).


    It sounds like you want to do defaulting of the ID to the next highest number.  There are no guarantees this will work without support from the database, but if you have low concurrency/contention for new IDs, you can do this in the _Created event on the entity type. 

    Anytime an entity is Created, its _Created method gets called.  Inside there, you could do a query that looked for the highest already allocated ID, and then set that value + 1 as the value of your new entity.

     

    • Marked as answer by gartnerj Wednesday, December 22, 2010 1:56 PM
    Tuesday, December 21, 2010 5:32 PM