How to display the last row in a table
I have a table that is constantly updating, and I always want to see the last row. How can I get my table to auto scroll?
Hi žabić,
there is a property called "top left visible row". You can use it to scroll your table.
edit:
Maybe this is not the exact name, but you can see an example here
Mike
Message Edited by MikeS81 on 05-27-2010 03:57 PM
Similar Messages
-
How to get the last row in a resultset or query
Hi All
Say If I have a complex query which returns a resultset say 15 rows. Now I want to limit the output showing only the last row.
How can we do thisKeep in mind Oracle does not keep "row" order as such. Unlike a graphical type db like Access, Oracle will not always give you back the results in order.
Even if you were to use a sequence, your query is never guaranteed to give back the results in the order you are expecting. You must then give an order by statement to all queries expecting the order.
Your definition of last row too is vague - if it is in fact the greatest amount, use the inline view suggestion. If you simply want to see the last inserted row, consider adding a last_update_date column inserting the sysdate (by a trigger perhaps). This would then allow you to see the last inserted row.
Enjoy! -
How to get the last row of a database table.
HI ,
I want to get record exactly from the last row of a database table.
How is that possible?Hi,
To fetch last record from an internal table, just do find the number of records in it and read using index.
DESCRIBE TABLE ITAB LINES L_LINES.
READ TABLE ITAB INDEX L_LINES.
You can also use LOOP .. ENDLOOP but the above method is better (performance wise).
using LOOP .. ENDLOOP.
LOOP AT ITAB.
**do nothing
ENDLOOP.
**process ITAB (Header record of ITAB).
**after ENLOOP, ITAB will have the last record of the internal table.
[here ITAB is internal table as well as header record.]
But what is the requirement?
If you are looking for the current record of an employee then you can use ENDDA = HIGH_DATE.
My advice is to review your requirement again and try to fetch only that record which you need.
Mubeen -
HELP! How te retrieve the last row in MYSQL database using Servlet!
Hi ,
I am new servlets. I am trying to retireve the last row id inserted using the servlet.
Could someone show me a working sample code on how to retrieve the last record inserted?
Thanks
MY CODE
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class demo_gr extends HttpServlet {
//***** Servlet access to data base
public void doPost (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
String url = "jdbc:mysql://sql2.njit.edu/ki3_proj";
String param1 = req.getParameter("param1");
PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
String semail, sfname, slname, rfname, rlname, remail, message;
int cardType;
sfname = req.getParameter("sfname");
slname = req.getParameter("slname");
rfname = req.getParameter("rfname");
rlname = req.getParameter("rlname");
semail = req.getParameter("semail");
remail = req.getParameter("remail");
message = req.getParameter("message");
//cardType = req.getParameter("cardType");
cardType = Integer.parseInt(req.getParameter("cardType"));
out.println(" param1 " + param1 + "\n");
String query = "SELECT * FROM greeting_db "
+ "WHERE id =" + param1 + "";
String query2 ="INSERT INTO greeting_db (sfname, slname ,semail , rfname , rlname , remail , message , cardType ,sentdate ,vieweddate) values('";
query2 = query2 + sfname +"','"+ slname + "','"+ semail + "','"+ rfname + "','"+ rlname + "','"+ remail + "','"+ message + "','"+ cardType + "',NOW(),NOW())";
//out.println(" query2 " + query2 + "\n");
if (semail.equals("") || sfname.equals("") ||
slname.equals("") || rfname.equals("") ||
rlname.equals("") || remail.equals("") ||
message.equals(""))
out.println("<h3> Please Click the back button and fill in <b>all</b> fields</h3>");
out.close();
return;
String title = "Your Card Has Been Sent";
out.println("<BODY>\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" );
out.println("\n" +
"\n" +
" From " + sfname + ", " + slname + "\n <br> To "
+ rfname + ", " + rlname + "\n <br>Receiver Email " + remail + "\n<br> Your Message "
+ message + "\n<br> <br> :");
if (cardType ==1)
out.println("<IMG SRC=/WEB-INF/images/bentley.jpg>");
else if(cardType ==2) {
out.println("<IMG SRC=/WEB-INF/images/Bugatti.jpg>");
else if(cardType ==3) {
out.println(" <IMG SRC=/WEB-INF/images/castle.jpg>");
else if(cardType ==4) {
out.println(" <IMG SRC=/WEB-INF/images/motocross.jpg>");
else if(cardType ==5) {
out.println(" <IMG SRC=/WEB-INF/images/Mustang.jpg>");
else if(cardType ==6) {
out.println("<IMG SRC=/WEB-INF/images/Mustang.jpg>");
out.println("</BODY></HTML>");
try {
Class.forName ("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection
( url, "*****", "******" );
Statement stmt = con.createStatement ();
stmt.execute (query2);
//String query3 = "SELECT LAST_INSERT_ID()";
//ResultSet rs = stmt.executeQuery (query3);
//int questionID = rs.getInt(1);
System.out.println("Total rows:"+questionID);
stmt.close();
con.close();
} // end try
catch (SQLException ex) {
//PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
while (ex != null) {
out.println ("SQL Exception: " + ex.getMessage ());
ex = ex.getNextException ();
} // end while
} // end catch SQLException
catch (java.lang.Exception ex) {
//PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
out.println ("Exception: " + ex.getMessage ());
} // end doGet
private void printResultSet ( HttpServletResponse resp, ResultSet rs )
throws SQLException {
try {
PrintWriter out = resp.getWriter();
out.println("<html>");
out.println("<head><title>jbs jdbc/mysql servlet</title></head>");
out.println("<body>");
out.println("<center><font color=AA0000>");
out.println("<table border='1'>");
int numCols = rs.getMetaData().getColumnCount ();
while ( rs.next() ) {
out.println("<tr>");
for (int i=1; i<=numCols; i++) {
out.print("<td>" + rs.getString(i) + "</td>" );
} // end for
out.println("</tr>");
} // end while
out.println("</table>");
out.println("</font></center>");
out.println("</body>");
out.println("</html>");
out.close();
} // end try
catch ( IOException except) {
} // end catch
} // end returnHTML
} // end jbsJDBCServletI dont know what table names and fields you have but
say you have a table called XYZ which has a primary
key field called keyID.
So in order to get the last row inserted, you could
do something like
Select *
from XYZ
where keyID = (Select MAX(keyID) from XYZ);
Good Luckwhat gubloo said is correct ...But this is all in MS SQL Server I don't know the syntax and key words in MYSQL
This works fine if the emp_id is incremental and of type integer
Query:
select *
from employee e, (select max(emp_id) as emp_id from employee) z
where e.emp_id = z.emp_id
or
select top 1 * from employee order by emp_id descUday -
How to Finding the Last Row Value in Datagrid?
Hi Everyone,
Thanks in Advance.
I need your help, to find the last row data in Datagrid.
Actually i am using Datagrid to display my Data in flex. In my data i stored the gender value of employees. So if the last row in my datagrid is "female" i need to be highlight that particular row. So please help me to solve this issue.
Thanks,
Charles. Jdatagrid.selectedIndex = datagrid.dataprovider.length;
^ something like this will select the last row in the datagrid.
if you need to check it's value, you might need to cast an object here, based on the index value, and check it's gender value.
datagrid.selectedIndex = datagrid.dataprovider.length;
if (datagrid.selectedItem["gender"] == "female") {
//handle here -
How to display the last value of a field in a group in the group header
I need to display the last quiz score from a group of quiz scores as part of the header of a group of units (the quiz score values are in the detail record). I can not use the group footer, which would be the natural place to find the last value. It must be in the group header because there will be a subsequent group within the unit group. In other words, the grouping is as follows:
Unit Group Header (Display last quiz score in unit)
SubUnit Group Header (Display other detail summaries)
Detail Record (including quiz score)
SubUnit Group Footer
Unit Group Footer
While there is a minimum/maximum summary function, there is not a first/last function.
Fuskie
Who is constantly amazed at the ability of users to request report features that are not easily implented through Crystal Reports...Hi Fuskie,
One suggestion to display the last quiz score in the Group Header, other than what had already been suggested, will be to use a linked subreport in the Group Header. It is not an efficient way to display the information, but it could do the trick.
Another suggestion will be to insert a subreport in the report header, then store the last quiz score in an array for each group, then share it with the main report and display the values in the appropriate group. In this way it will only connect twice to the data source, one for the main report and once for the subreport, instead of multiple connection for each group.
Finally, the most efficient way will be to have this value calculated on the database side using a command object or a stored procedure.
Patrick -
I have 10 rows in my table and I have to retrive last row using rownum.
For this I use
SELECT * from <table_name>
where rownum<=10
minus
SELECT * from <table_name>
where rownum<=9
The result is no rows selected
In the same case if I use
SELECT rownum from <table_name>
Where rownum <= 10
minus
SELECT rownum from <table_name>
where rownum <=9
The result is 10
Why this happend.
If the result is 10, then why the row whose rowid is 10 is not retrivedAll
Please bear in mind that ROWNUM is an attribute of the query NOT the table. The last row returned by an unORDERed SELECT statement may be the most recently inserted row but is not guaranteed to be so.
The only way of assuring yourself of returning the most recent row is either to timestamp all your tables with a date_created column or to use a primary key with an ascending value.
rgds, APC -
How to display multiple selected rows in a table inside a popup?
Hi,
I have a table on which multiple selection is enabled. I am able to get hold of multiple selected rows i.e. i am able to iterate over the selected row keys and print their values. Now, my problem is how to display the contents of all the selected rows in a popup? I get the details of only one row when I launch the popup.
Thanks
KaranHi,
Not confident if this works or not but just try it...
1. create a ViewLink between the same view Object.
The source and destination wil be the same Vo and the source and destination attribute will be the pk of both Vos.
2. Update the changes in Appln Module.
Open the AM and in DataModel tab .
select the Same VO from which you created table in the DataModel Listbox and select the VL in the "Avaible View Objects" List Box. Add under it(selected vo in datamodel listbox).
3. Refresh DataControl accordion.
4. in your jsff page drag and drop the child vo as a table..
See if it works
Regards,
Santosh. -
How to find the LOCKED ROWS in a table?
Not locked objects, but for a table the locked rows.
Check below links :
http://www.jlcomp.demon.co.uk/faq/locked_rows.html
How to find the locked row.
who are waiting for same record?
HTH
Girish Sharma -
How to save the selected rows from Advance table into database
Hi
I have requirement like..
In custom page , Manager Search the Candidates and selects the candidate ROWS from advance table.
The reqt is how to save the selected multiple rows into the database.hi Reetesh,
In Custom page
Supoose the Recruiter Search is for Position Finance Mangager , it retrieves 100 rows , out of which Recruiter select 10 rows .
So in Such scenario how to save this 10 rows against Recruiter
, i mean , Is i need to create custom table, to save Recruiter , these selected 10 rows.
I hope u understand my question -
Using Firefox 4.0.1, the IBM SVC console and the IBM HMC console both have the last line of selectable items either cut off, or overlaying the prior row of displayed items. Junked version 4 and reverted back to 3.6.17.
Seeing the same problem using the HMC with FF7 beta.
-
Displaying the last row value + 1
Hi, I am sure the answer is out there, I just can't find despite hunting around. So a point in the right direction would be great if possible:
I am trying to display the 'future' number from an auto update primary key in an access d/base. I am getting the current number with the code below which obviously means that I just need to add 1 to it; if only it would let me have the result as an integer, but I can't seem to achieve that (can only get a string) therefore tried to make the string an integer, update, change it back & then display in textField, but I can't achieve that either...please help?
public void findCurrentRow()
try
query = "SELECT (customerID) from Professional";
stmt = myConnection.createStatement();
rs = stmt.executeQuery(query);
int i = 1;
while(rs.next())
rowNumber = rs.getString(i);
id.setText(rowNumber);
id.setEditable(false);
rs.close();
catch (SQLException ex)
fatalError(ex);
}I meant to ask why this did not work for you below ?
int rowNumber = rs.getInt(1);//returns an int type
the resultset method getInt() is not returning a integer?
I guessed that you were getting a non numerical return so you decided to return the value to a string getString() and see what was happening like the record value being returned was a float or other non-int type.
int rowNumber = Integer.parseInt(rs.getString(1));
A little off topic you could write your query to be
SELECT (WHATEVER) +1 FROM TABLE; //adds 1 to value
or if the DB has a nextVal func for sequences use that.
Ray -
How to delete the committed row from a table from its VOImpl class ??
I am new to ADF and I have problem to solve. To perform roll back I am using fetching key before roll back and setting it after undo operation, so that I can stay back in the currently selected row. But in my case I am using application model commit for one LOV attribute selection in the row. So when ever I am performing roll back operation after inserting a row, the values other than this committed LOV attribute gets roll backed, but I need remove the entire row from table. Does there any option to remove a row based on the attribute values of a row from VO's row implementation or from bean class in a performance optimized way ?
Thanks in advance..........http://java.sun.com/javase/6/docs/api/javax/swing/table/DefaultTableModel.html#removeRow(int)
Why did you mark it answered but gave no dukes to finalight? That's not how it works.
You should mark his answer as correct and give him at least one duke, for the effort! -
How to highlight the first row of a table
When entering the form, how do I get the first row of the table to be highlighted when it has not been selected yet? There is already data in the table. Thanks.
AllysonAny ideas on what would cause this NOT to work? I added this row right after the table is created and populated and it is still not highlighted when I enter the form. The snippet of code that does this is:
MyTableModel modelS = (MyTableModel)dataModel.get("S");
jTable1 = new JTable(modelS);
jTable1.setRowSelectionInterval(0,0);MyTableModel is this:
class MyTableModel extends DefaultTableModel {
public MyTableModel(Object[] columnNames, int numRows) {
super(columnNames, numRows);
public boolean isCellEditable(int row, int column) {
if (TableKey == 'S') {
if (column == 6) {
return false;
if (TableKey == 'O') {
if (column == 0 || column == 4 || column == 5) {
return false;
if (TableKey == 'P') {
return false;
return true;
}Can anyone help? Thanks.
Allyson -
How to get the selected rows in a table
Hi,
How to get the ids of all the selected rows. On Page load a query is executed that shows the data in a table with a checkbox in the first column to select the rows and delete. Now if a user select multiple rows how do I get the ids of selected rows in the backend code.
ThanksPlease search the forum before posting questions.
refer following thread for table selection.
Re: Record selection with MessageCheckBox and print the selected record.
--Prasanna
Maybe you are looking for
-
Data allocation for internal table rows Dynamically
Hi Friends I have requirement like below: I have one internal table with 400 amounts columns, I will get the value from another program that indicates to which column I have to add the values. I dont want to write the case statement because I need to
-
Source determination with referance to quota arrangement
Dear all I had created quota for vendor A & Vendor B for a material M100, I had also defined quota arrangement usage in SPRO ( 3), While creation of PR for this material M100, I had selected the tick for source determination, But still system is not
-
Can we extract the timesheet in excel format from non-SAPGUI to SAPGUI
Can we extrat the timesheet in excel format from NON-SAPGUI network to the SAPGUI network
-
the video is only 20 minutes long. I've exported longer videos in less than 2 hours before so I have no idea what the issue is. The first time I tried to export this same video it started at saying remaining time was around 8 hours, went all the way
-
Lock screen issues when deleting notifications
I am having a recurring problem where the phone gets stuck when I try to delete a notification from the lock screen. When I swipe and hit Trash, the screen sends me to the password entry screen but every time I hit a button, the screen only bounces t