Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding an id column to an existing table

561854May 27 2008 — edited Mar 4 2009
I would like to add an id column to an existing table and populate this column for the existing records. For any new inserts I would like to use the next id in sequence.

I believe a sequence and a trigger on insert would be the best way to accomplish the second requirement. I would like to know how to do the first, i.e. handle the existing rows given that I will be using a sequence and trigger for all subsequent rows.

I've never created sequences or triggers before so any advice would be appreciated.

-=beeky

Comments

Hamza Al-abbasi
Answer

Hello Ace1,
Can you give a screen shot?

Marked as Answer by Ace1 · Feb 15 2022
Ace1

Sure,

image.png

Hamza Al-abbasi

What is the problem with zoom out ?

Ace1

Hamza,
Problem with a zoom out occurred with items but it was just a workaround. I'd like to have the IG with feature like I pasted above on the screenshot

Hamza Al-abbasi

IG Cookbook app have an example like that on my workspace :
Workspace: hamzasoft
Username/Password: demo/demo0000
Application 138659 - Page 5

Ace1

It's not a solution, I need to dynamically sum a column inside the IG, not as an item in another region.

Hamza Al-abbasi

This is not a built-in feature, it needs more JS, in this case it will work if your IG pagination is scroll with aggregate. I have an example on my workspace :
Workspace: hamzasoft
Username/Password: demo/demo0000
Application 62472 - Page 17

Ace1

Hamza, thanks a lot! This is exactly what I needed

John Snyders-Oracle

For newer APEX releases take a look at
JSDoc: Interface: model (0 Bytes)properties aggregates.
For example EMP table SAL column add to JS init code:

function(options) {
    options.defaultGridColumnOptions = {
        aggregates: ["SUM"]
    };
    return options;
}

This is much less code than the old way!

Ace1

@john-snyders-oracle thanks a lot! It's working great but I struggle with one thing, how to round values?
image.png

John Snyders-Oracle

I think all you need to do is give the column a format mask. I tried FML999G999G999G999G990D00. This is the declarative option Format Mask for a number column.
One other note for using aggregates option is that the IG must have a primary key defined.

Ace1

@john-snyders-oracle I tried with FML999G999G999G999G990D00 and it's still the same, I have a number column type and a primary key in my IG.

John Snyders-Oracle

Just give the column a format mask.

Mohamed Sameer

@hamza-alabbasi
Do you have a JS function to get a sum of multiple columns in IG

Hamza Al-abbasi

Hi md-sameer,
Please open a new thread and explain your issue.

User187849

hi ,
I have added the same logic in SUM column properties but I couldn't get the total value

function(options) {
    options.defaultGridColumnOptions = {
        aggregates: ["SUM"]
    };
    return options;
}
Robin Biju

Hi John Snyders-Oracle, can this value assign to any page item?
Thanks.

John Snyders-Oracle

@robin-biju When using model field option aggregates the aggregate value cannot be stored directly in an item. There are ways to data out of a model into an item but it can be trickier for aggregate rows. (Model method getAggregateRecord is not documented and not clear how useful it is.)
If you want to save the aggregate value to a page item you can use the method shown in the IG Cookbook page 5.

1 - 18
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 1 2009
Added on May 27 2008
6 comments
24,479 views