MAX(ROWID) and inserting rows at the end of the table
Hi,
I know this will be another lame question but I simply didn't find the answer anywhere. I create ID (primary key) for rows manually so I have this code:
String query = "SELECT * FROM CIS_SEG_SKUPINY WHERE ROWID=(SELECT MAX(ROWID) FROM CIS_SEG_SKUPINY)";
rset = stmt.executeQuery(query);
if (!rset.next()) {
<p style="padding-left:10px">newID = new Number(1);
System.out.println(newID);</p>
else {
<p style="padding-left:10px">rset.beforeFirst();
while (rset.next()) {
<p style="padding-left:20px">int lastID = rset.getInt("ID");
System.out.println(lastID);
newID = new Number(lastID + 1);
System.out.println(newID);
}</p>
}</p>
css.setId(newID);
Row globalsRow = getGlobals().first();
css.setKodSegSkupiny((String)globalsRow.getAttribute("GroupCode"));
css.setPopis((String)globalsRow.getAttribute("Description"));
css.setBarva((Number)globalsRow.getAttribute("Colour"));
getDBTransaction().commit();
When the table is empty newID is set to 1 and row inserted. Now I have one row in the table (with ID=1) so newID is set to 2 and row inserted BUT it is inserted BEFORE the first row. So when I try to insert third row lastID is 1 not 2. I tried to find some command which would insert new row after the last one but unfortunately I wasn't successfull.
Edited by: Herald on Mar 28, 2009 11:11 AM
Herald,
I am sorry to say that there are so many things wrong with your approach, that I don't know where to begin...
1). ROWID is a pseudo column in Oracle.. It has no meaning of first, last, middle, or otherwise. SELECT MAX(ROWID) will get you some row.
2). In a relational database, there is no concept of first or last row in a table. If you expect the rows in some order, use an order by.
3). Ignoring your implementation and addressing your intent - you should not be creating a primary key by getting the max already in the table and adding one. You will, using your technique, get duplicates in a multi-user scenario. If you fix your implementation to not give duplicates in a multi-user scenario (no, I won't show you how), you will use a table lock, and therefor inhibit scalability in a serious way.
The proper and commonly accepted way to generate a numeric primary key in Oracle would be to use a sequence and a trigger to populate the sequence. Lots of examples to be found in this forum, but just have a read of the ADF Developers Guide for Forms/4GL Developers (for 10g) or the Fusion Developers Guide (for 11g) to find one. The term to search for would be DBSequence.
John
Similar Messages
-
Need to add a new row at the end of the table
Experts,
working jdev 11.1.1.3.0
i am adding row programetically, my requirement need to add the row at after last row.
i tried different ways.
Row newLastRow = getPWBBidLaneVO().last();
int lastRowIndex = getPWBBidLaneVO().getRangeIndexOf(newLastRow);
getPWBBidLaneVO().insertRowAtRangeIndex(lastRowIndex - 1,
laneRow);
this is giving --- java.lang.ArrayIndexOutOfBoundsException: 0
and
http://kohlivikram.blogspot.com/2008/10/add-new-row-in-adf-table-on-button.html --- its giving index out of bound because vo.getRangeSize() is 25. We set this value at vo for performance improment suggestions.
is there a way to add a new row at the end of the table?Add this to the view row impl class
public void insertRow(Row row) {
//go to the end of Rowset if it has rows
Row lastRow = this.last();
if (lastRow !=null){
//insert new row at the end and make it current
int indx = this.getRangeIndexOf(lastRow)+1;
this.insertRowAtRangeIndex(indx,row);
this.setCurrentRow(row);
}else { // empty Rowset
super.insertRow(row);
} -
Row getting added in the end of the scroll
Hi -
I am using a scroll area on a page on level 1. The issue iam encountering is that when ever i click the plus sign to add a second or third row (assume one record already exists in scroll 1) , the row gets added in the end of the scroll and also the fields are blank. However as delievered the new row should get added on the top of the scroll meaning 1 of 2 not 2 of 2, and also it should carry forward the values from the prior row. Please any suggestion or help is greatly appreciated.I figured it out. The reason it was happening was because, my scroll record had another key field after EFFDT and EFFSEQ, due to which the delivered copy forward logic for new rows in scroll did not work and the row was getting added in the end or after the first blank row always.
-
in numbers, how would I make a line for each family (100+) a column for each fundraiser. and at mid year, and year end be able to print an alphabetical listing?
example: entertainment books Chip Shoppe Yankee Candle
Smith $350 $245 $100
Total at the end of the line, but I could live without. I am just trying to lose the paperwork, and have it in the ipad for when parents approach me at meetings.
Help!HI m,
Using Numbers '09 (the Mac version), I'd use a table with one header row and two header columns.
Family Total Ent.Books Chip S. Y. Candle
Smith, J $695 350 245 100
Jones, T $765 250 445 70
An ascending sort on column A will put the families in alphabetical order (and carry the rest of the row along with them).
The formula =SUM(2) in B2, and filled down from there, keeps the total for each family right beside the family name.
You could add a Footer row at the bottom to keep totals for each column. Formula for column B: =SUM(B)
I would leave the currency signs ($) off the amounts—they just clutter up the table.
This assumes that the features listed are all supported on Numbers for iOS, the version running on your iPad.
Regards,
Barry -
The tabs bar on 3.6 Firefox now focuses on the last tab in the row. This means that I can only effectively see one tab, unless I use the arrow button to scroll back through all the tabs. I am used to scrolling some, when there are a dozen tabs open, but How do I make the tab bar static, they way it used to be, so it stands still when I click on the last tab in the row.??
Thanks for taking a stab at it: that didn't prove to be the problem. That option in the settings for tabbed browsing was not checked.
I may be a bit behind the times: I am used to tabbed browsing showing all the tabs it possibly can, instead of just the last one. Sometimes it won't even show the last tab: I can have 15 tabs open, and not see a single tab. I've been confused by this into closing a window with lots of tabs open, because it looks like a single page-window.
My main problem with the tab-bar flashing to the end of the row is that it means a great deal more mouse-clicking around to browse.
I haven't tried installing the latest beta. Maybe that would fix the problem.
Toddo -
Add JTable Row Headers At The End Of The Rows(At Right)?
hi all
i got this example for adding JTable Row Headers,but it adds the headers at the left(beginning of the row)
and i want to add the headers at the end of the row(at right),any ideas how to do that?
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.AbstractListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
* @version 1.0 11/09/98
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
RowHeaderRenderer(JTable table) {
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
setText((value == null) ? "" : value.toString());
return this;
class RowHeaderExample extends JFrame {
public RowHeaderExample() {
super("Row Header Example");
setSize(370, 150);
ListModel lm = new AbstractListModel() {
String headers[] = { "Row1", "Row2", "Row3", "Row4"};
public int getSize() {
return headers.length;
public Object getElementAt(int index) {
return headers[index];
DefaultTableModel dm = new DefaultTableModel(lm.getSize(), 4);
JTable table = new JTable(dm);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setRowHeight(18);
JList rowHeader = new JList(lm);
rowHeader.setFixedCellWidth(50);
rowHeader.setFixedCellHeight(18);
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
JScrollPane scroll = new JScrollPane(table);
scroll.setRowHeaderView(rowHeader);
getContentPane().add(scroll, BorderLayout.CENTER);
public static void main(String[] args) {
RowHeaderExample frame = new RowHeaderExample();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.setVisible(true);
}fixed by:
list.setBackground(table.getTableHeader().getBackground());here's the full code:
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
* @version 1.0 11/09/98
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
JTable table;
RowHeaderRenderer(JTable table) {
this.table = table;
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
list.setBackground(table.getTableHeader().getBackground());
setText((value == null) ? "" : value.toString());
return this;
class RowHeaderExample extends JFrame {
public RowHeaderExample() {
super("Row Header Example");
setSize(370, 150);
setLocationRelativeTo(null);
DefaultListModel lstModel = new DefaultListModel();
lstModel.addElement("Row 1");
lstModel.addElement("Row 2");
lstModel.addElement("Row 3");
lstModel.addElement("Row 4");
DefaultTableModel dm = new DefaultTableModel(lstModel.getSize(), 4);
JTable table = new JTable(dm);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setRowHeight(18);
JList rowHeader = new JList(lstModel);
rowHeader.setFixedCellWidth(50);
rowHeader.setFixedCellHeight(18);
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
JScrollPane scroll = new JScrollPane(table);
scroll.setRowHeaderView(rowHeader);
table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
getContentPane().add(scroll, BorderLayout.CENTER);
public static void main(String[] args) {
RowHeaderExample frame = new RowHeaderExample();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.setVisible(true);
} -
I'm using FF 3.5.18 and I do not want newer versions because : using in the Open in New Tab page opens the near tab and not as a FF 3.5.18 or is it possible to do that open in new tabs would be the end. of the new FF version
You can change a preference to make tabs open
# at the end of all open tabs
# immediately after the current tab.
See: http://kb.mozillazine.org/About:config
*Type '''about:config''' in the URL bar and press the Enter key.
*If you see the warning, accept it (promise to be careful).
*Filter = browser.tabs.insertRelatedAfterCurrent
*Look at the "Value" column ('''false'''=open at end, '''true'''=open after current tab); Value = true is the default.
*Double-click that preference to toggle the value from true to false, or false to true
*Restart Firefox (File > Restart Firefox)
See: http://www.mydigitallife.info/2010/02/01/change-firefox-to-open-new-tab-at-far-right-end-of-tabbar-disable-insert-next-to-current-active-tab/ -
Extra Blank line inserted at the end of the target file
Hi,
This is File to File senario and target files created with a extra blank line at the end of the file.
Below is the source file structure and the content.
<ns0:MT_MOD_FL xmlns:ns0="http://file2file/MES">
<EMPLOYEE>
<ID>12</ID>
<Name>SREENI</Name>
<Designation>M2</Designation>
</EMPLOYEE>
<EMPLOYEE>
<ID>121</ID>
<Name>RAJA</Name>
<Designation>M3</Designation>
</EMPLOYEE>
</ns0:MT_MOD_FL>
Below is the generated target file
12 SREENI M2
121 RAJA M3
Here Generated target file suppose to have only two line instead of 3.
What exactly do i need to change to generate the file with 2 line.
I am not using any mapping as both source and target message structure are same.
IN FCC i used only fieldSeparator, even i have not used endSeparator.
Thanks in Advanace...Hi! Raghu,
Just go through the below Help..documantation
[http://help.sap.com/saphelp_nw04/helpdata/en/0d/5ab43b274a960de10000000a114084/frameset.htm]
NameA.endSeparator
To define an additional string as a separator after the last column in a row, specify it here. The system skips this string when it processes the last column (otherwise the system would treat it as part of the last column).
NameA.fieldSeparator
If you make an entry here, the system expects that the structure contains the specified character string (one or more characters) as a separator between the individual columns.
If you have not made an entry for fieldFixedLengths, this is the only specification to identify the individual columns in a row.
If you made a specification for fieldFixedLengths, the extra length of the separator is taken into account, but no further consistency checks are performed.
Regards::
Amar Srinivas Eli -
I am writing an iBook, and I need to insert a page in the middle of the section without disrupting the layouts on the following pages. I keep trying to insert, but it always sticks a new page at the end of the section. Is there any way to add a page, or move pages around in an iBook?
Using the thumbnail view on the left, select the page you want a new one after, then right click and choose 'Insert Page'....that should do it.
-
I want my new tabs to open at the end of the row of tabs, how do I do that?
When I open a new tab, I would like it to open at the end of the row of tabs, not next to the tab I'm on now. I'm used to it opening on the end like it did in older versions of Firefox. I'm sure this is an easy fix but I can't find anything in options and I'm getting frustrated.
Thanks!Hello callagalla, go to [http://kb.mozillazine.org/About:config about:config] find(or copied/paste from there) '''browser.tabs.insertRelatedAfterCurrent''' and double-click on it to make it FALSE.
thank you -
Compare 2 tables and insert rows missing in each table.
I have a tough situation. I have two exact tables- one online and one offline database. I know that there are missing rows of data from each table, so I need to make a comparison of one table and insert rows that do not exist. I was thinking to try this, but it took over 3 hours to run and did not return anything:
insert into t
select * from t a
where not exists (select * from [email protected] b
where a.col1 != b.col1
and a.col2 != b.col2
and a.col3 != b.col3);
and it goes on for another 7columns.
The trouble I have is to include a date clause so that the query can be broken down into running only a few months of data comparisions at a time- the records go back 4 years to compare. Also is there a way to write this so that it will query both tables at the same time in order to speed things up- or is one table at a time the best advice? Each table has over 100 million records to compare, that's why I was hoping to use a date criteria since one column is date.
Let me know what you advise to make this work, I hope I was on the right track.Not sure if the MINUS operator will perform better with your data set but;
SQL> create table t1 (some_id number, some_date date)
Table created.
SQL> create table t2 (some_id number, some_date date)
Table created.
SQL> insert into t1 values (1, trunc(sysdate))
1 row created.
SQL> insert into t1 values (2, trunc(sysdate-5))
1 row created.
SQL> insert into t1 values (4, trunc(sysdate-90))
1 row created.
SQL> insert into t2 values (1, trunc(sysdate))
1 row created.
SQL> insert into t2 values (3, trunc(sysdate-10))
1 row created.
SQL> insert into t2 values (5, trunc(sysdate-100))
1 row created.
SQL> select * from t1
SOME_ID SOME_DAT
1 07-07-30
2 07-07-25
4 07-05-01
3 rows selected.
SQL> select * from t2
SOME_ID SOME_DAT
1 07-07-30
3 07-07-20
5 07-04-21
3 rows selected.
SQL> insert into t1 (
select some_id, some_date from t2 where some_date between sysdate-50 and sysdate
minus
select some_id, some_date from t1 where some_date between sysdate-50 and sysdate)
1 row created.
SQL> insert into t2 (
select some_id, some_date from t1 where some_date between sysdate-50 and sysdate
minus
select some_id, some_date from t2 where some_date between sysdate-50 and sysdate)
1 row created.
SQL> select * from t1
SOME_ID SOME_DAT
1 07-07-30
2 07-07-25
4 07-05-01
3 07-07-20
4 rows selected.
SQL> select * from t2
SOME_ID SOME_DAT
1 07-07-30
3 07-07-20
5 07-04-21
2 07-07-25
4 rows selected. -
How to add an extra row at the end of the Grid?
Hi gurus,
I am getting result from the select query which has 4 columns.
I got the requirement to display the sum of those columns as the last row.
How can i add the another row at the end of the iGrid ?
Data would look like
Sno Col1 Col2 Col3 Col4
1 4 6 1 6
2 5 8 0 8
3 6 1 2 5
Sum 15 14 3 19
Do i have to add transformation to the sql query? or
Can i add row to the display tempalate by accessing the Gridobject?
Please help.
Thanks
Vansi
Edited by: vamsi P on Feb 12, 2008 8:49 PM
Edited by: vamsi P on Feb 12, 2008 8:49 PMHi Vamsi,
There are a few options ...
1) The one suggested by Prasanna
2) Loop through all rows via JavaScript and use the GridObject methods to set cell values and then perform an applet.refreshGrid( false )
3) Apply an Inline transform
4) Use a stored procedure to return the results and the totals as one recordset.
The stored procedure would be the fastest for runtime.
The Iniline XSL transform would be the second fastest. If you specify the XSL in a generic way, you may even be able to reuse it in other scenarios. If you hardcode the fields in the XSL, it would be a matter of simple code adjustment when you encounter a similar scenario.
Hope this helps.
Cheers,
Jai. -
Set_ready_for_input and insert row.
hy guys, i having an issue with an alv oo.
i have created a button on my toolbar to make my alv editable by using
if grid->is_ready_for_input( ) EQ 0.
CALL METHOD grid->set_ready_for_input
EXPORTING i_ready_for_input = 1.
and that works fine.
all the editable fields are in edit mode (all non keywords fields).
the issue is this, i want the user to be able to insert a new row.
When the alv switches to the edit mode, 2 buttons add row and delete row are automatically add to the toolbar.
But when you have a new row, that row should completely be editable, but in my case the row is non editable.
so where does the event add rows is triggered? when i'm trying to debug the adding row action, the program never stop, add immediately the row.
I try to see if the handle data changed was trigged but neither this was triggered.
How can i make the added to be immediately editable?
Edited by: EBONGUE ANDRE on May 27, 2010 4:08 PMYou should also set the EDIT option in your Layout.
gs_layout-edit = 'X'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout " <
CHANGING it_outtab = gt_outtab.
Check program BCALV_EDIT_01.
Regards,
Naimesh Patel -
Everytime I try it inserts the page at the END of the document. The HELP is no help, and I can't find any other documentation on being able to do this. Appreciate the feedback. Thanks! - ph
AP,
As Fruhulda notes, a Section Break is an Inline character that will move all text below it to the next page. With a combination of graphics and text, and with the graphics having the property of Object Causes Wrap turned on, you will get these apparently odd behaviors. This is why I often favor the Page Layout mode myself. As many experienced users will say, you can do anything in a WP doc that you can do in a PL doc, but in my opinion the WP features often get in the way of simple operation when graphics are involved.
Glad you are on track now.
Jerry -
i have the adobe cloud 9.99/ month photography package i downloaded lightroom 5.4, it told me it was a trial version, and i'm now at the end of the trial and it won't let me download the full version and i don't have a serial number. also, when i click buy, i get an error message saying, "application not found."
There are two different LR’s, one with a serial-number licensing and one with a CC-signin license.
You should uninstall the serial-number LR you have installed, then
Quit the CC Desktop application,
Restart the CC Desktop application—this will rescan what you have installed and not see LR,
LR will now be on the CC Desktiop apps list, so install that.
Maybe you are looking for
-
I have more than one tab open, and I can usually move them around and organize them freely. But a couple of days ago when I tried to move them they just get stuck and stay in the spot it was put in when i created the new tab. I didn't download or cha
-
Everytime I try to use the video camera, my ipod automatically restarts???
Everytime I try to use the video camera, my ipod automatically restarts. I just need to bring the clicker to the Video section on the main menu for it to turn on and off again. I have to scroll over it really fast so it doesn't restart. My dad bought
-
MY Itunes is ****** up!!!!!!!
When ever I try and sync my ipod it just gets stuck , what can I do about that ?
-
Can all three be installed on same box
Can 10g db, AS10g Rel 2 and Developer Suite 10g be installed on same machine? Thx
-
(URGENT) How to recover tablespace/datafile from an old backup ?
Hello, I'm in charge of installation of IBM Websphere Commerce with an Oracle DB. When I installed this software I do a "shutdown immediate" and copy all the files (data, ctl & redo) in an other directory a month ago. I have some issues on a specific