How to retrieve the Last sequence value of a sequence ?
Can anybody help me out regarding how to retrieve the last executed number or value of a sequence ? As dba_sequence.last_number does not show the original picture of that last value ?
Rajesh Lathwal wrote:
Last Number Selected From Sequence :
SELECT sequence_name, last_number
FROM user_sequences;That's wrong, this is taking the CACHE in account :
SQL> create sequence seq ;
Sequence created.
SQL> select seq.nextval from dual;
NEXTVAL
1
SQL> SELECT sequence_name, last_number
2 FROM user_sequences where sequence_name='SEQ';
SEQUENCE_NAME LAST_NUMBER
SEQ 21
SQL> select seq.currval from dual;
CURRVAL
1
SQL>Nicolas.
Similar Messages
-
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 retrieve the last 5 accessed record ??
How to retrieve the last 5 accessed record ??
I am using a field for storing the accessed time.
Pls help with regard to this.
Thanks in Advance.
JGDepending on your used databasee version, there are several options available, here are just a few examples:
Sorted Inline-Views & rownum:
SELECT *
FROM (SELECT *
FROM user_objects
ORDER BY timestamp desc)
WHERE ROWNUM <= 5;
;Inline-View with analytic function:
SELECT *
FROM (SELECT uo.*, ROW_NUMBER() OVER (ORDER BY timestamp desc) rn
FROM user_objects uo
WHERE rn <= 5;
;C. -
How to get the last "reported" value in a cross tab
Dear all,
based on a BeX Query Universe I have built a report with a cross tab in webI.
Maybe you can help me with the following issue. There I have a problem: I want to get in the Total-column always the last reported value, e.g. for Number Total Customers "66", not for Mar or Apr, because they are null.
Calendar Month |Jan| |Feb| |Mar| |Apr| |Total|
Number Total Customers |54| |66| | | | | 66
Number Active Customers |57| |71| | | | | 71
I hope that you understand my problem and could help as soon as possible.
Thanks a lot in advance for your support.
Best regards.
Edited by: HOLWUE on Feb 8, 2010 1:40 PMHi,
If this question is related to Webi then post in the below forum.
http://scn.sap.com/community/businessobjects-web-intelligence/content?filterID=content~objecttype~objecttype[thread]
Regards,
Sujit. -
How to find the last string value in dynamic object?
Hi All,
I am trying to find the last string value in dyanamic objects,Any one have solution for this.
Ex:
my data :12347-ebjdone-525-ecgfjf-25236-defdafgdeg
And i want to show the output is :defdafgdeg
Any ideas:
Thanks
SriniFor oracle try using oracle function.
e.g.
SELECT reverse(substr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),1,instr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),'-','1'))) from dual
Object definition might look like:
reverse(substr(reverse({ObjectName}),1,instr(reverse({ObjectsName}),'-','1')))
Regards,
Kuldeep
Edited by: Kuldeep Chitrakar on Feb 12, 2010 8:12 AM -
How to retrieve the data/property value from portalapp.xml
Hi I would like to retrive the some common data from the portalapp.xml file
<application>
<application-config>
<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
</application-config>
<components>
<component name="DynZMMGR">
<component-config>
<property name="ClassName" value="DynZMMGR"/>
<property name="SecurityZone" value="DynZMMGR/high_safety"/>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/DynJspZMMGR.jsp"/>
</component-config>
<component-profile/>
</component>
<component name="dynpagedel">
<component-config>
<property name="ClassName" value="dynpagedel"/>
</component-config>
<component-profile/>
</component>
<component name="VARIANTLIST">
<component-config>
<property name="ClassName" value="com.sap.ep.r3rpts.VARIANTLIST"/>
<property name="SecurityZone" value="com.sap.ep.r3rpts.VARIANTLIST/high_safety"/>
</component-config>
<component-profile/>
</component>
<component name="DynZMM33">
<component-config>
<property name="ClassName" value="DynZMM33"/>
<property name="SecurityZone" value="DynZMM33/high_safety"/>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/DynJspZMM33.jsp"/>
</component-config>
<component-profile/>
</component>
</components>
<services/>
</application>
The above is my portalapp.xml file .
I want to retrieve the common data across the component.
These datas are common across the components .
I kmow by putting the data inside the
component name="DynZMM33">
<component-config>
<property name="ClassName" value="DynZMM33"/>
<property name="SecurityZone" value="DynZMM33/high_safety"/>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/DynJspZMM33.jsp"/>
</component-config>
<component-profile>
<property name="UserID" value="userid"/>
<property name="password" value="password"/>
</component-profile>
</component>
this becoms component specific ... which I can retriev the by using
String ClientVal = request.getComponentContext().getProfile().getProperty("Client");
in doContent() method ..
But this way i have to specify these properties in all the component.. which is repetetive in nature.
I would rather put it in common location and want to retrieve the info from the portalapp.xml...
How to achieve this
I am using "AbstractPortalComponent" .
thanks
pkiranHi Prashanth,
see Reading another iView's profile personalized values and Validate PCD URI
Anyhow, maybe you should implement a service which returns the values (from the service profile). This would be more clean for accessing global values.
Hope it helps
Detlev -
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 retrieve the last inserted row
This may be a question with a very known answer but I couldn't find any within this forum.
What is the proper way to retrieve the just inserted record ?
I'm accessing the DB from external Java and at this moment I use a timestamp column in order to retrieve the inserted row. So I generate an unique timestamp ('20020615184524356') which I inserted during the insert operation. I retrieve the just inserted row using "select * from fooTable where(timestamp='20020615184524356')".
Is this the general idea or am I totally wrong ?hi Shaik Khaleel,
Just wanted to clarify my doubts regarding rowid.
Please refer the subject as "abt rowid" in previous posting and ur reply for that was
"its an unique number throughout the database, its an hexadecimal number. it assigns the rowid of the deleted row in future , but not to the immediate insertation row."
As u have mentioned the rowid of the deleted row can be assigned to a new row in future,
wont the following query fail.
select * from temp where rowid=(select max(rowid) from temp); -- in oracle. ~chandru -
How to calculate the Last sold value
Hi All,
Can we get the material last sold price based on the materials, suppose 20/11/2007 my material has been sold with value of $100, on 15/11/2007 same material sold with value of $80, so in my report coloum i wolud like to see the value as $80,
Best regards,
Rams.Hi Sam,
I have already tried, but the result is showing wrong, could u pls provide any other solution.
Best Regards,
Rams. -
How to retrieve the value of last identity has been updated in a database?
how to retrieve the value of last identity has been updated in a database
Hi,
Oracle 10g, FGA - Fine grained auditing, supports DML statements (9i only select).
Set up FGA using the DBMS_FGA.ADD_POLICY procudure:
sql> BEGIN
DBMS_FGA.ADD_POLICY (
policy_name => 'AUD_EMPLOYEE_SAL',
object_schema => 'HR',
object_name => 'EMPLOYEE',
audit_column => SALARY',
audit_condition => '',
statement_type => 'UPDATE');
END;
NEXT:
sql> SELECT dbuid, lsqltesxt FROM sys.fga_logs$;
The database inserts the audit record into the FGA_LOG$ table using an autonomous transaction; even if you roll back the update statement, the update action will still be logged in this table. The fga_log$ tracks the session, machine id, timestamp, schema, scn, etc:
SQL> desc fga_log$
Name Null? Type
SESSIONID NOT NULL NUMBER
TIMESTAMP# DATE
DBUID VARCHAR2(30)
OSUID VARCHAR2(255)
OSHST VARCHAR2(128)
CLIENTID VARCHAR2(64)
EXTID VARCHAR2(4000)
OBJ$SCHEMA VARCHAR2(30)
OBJ$NAME VARCHAR2(128)
POLICYNAME VARCHAR2(30)
SCN NUMBER
SQLTEXT VARCHAR2(4000)
LSQLTEXT CLOB
SQLBIND VARCHAR2(4000)
COMMENT$TEXT VARCHAR2(4000)
PLHOL LONG
STMT_TYPE NUMBER
NTIMESTAMP# TIMESTAMP(6)
PROXY$SID NUMBER
USER$GUID VARCHAR2(32)
INSTANCE# NUMBER
PROCESS# VARCHAR2(16)
XID RAW(8)
AUDITID VARCHAR2(64)
STATEMENT NUMBER
ENTRYID NUMBER
DBID NUMBER
LSQLBIND CLOB
SQL> spool off -
How to retrieve the values from a table if they differ in Unit of Measure
How to retrieve the values from a table if they differ in Unit of Measure?
If no data is read
- Insure that you use internal code in SELECT statement, check via SE16 desactivating conversion exit on table T006A. ([ref|http://help.sap.com/saphelp_nw70/helpdata/en/2a/fa0122493111d182b70000e829fbfe/frameset.htm])
If no quanity in result internal table
- There is no adqntp field in the internal table, so no quantity is copied in itab ([ref|http://help.sap.com /abapdocu_70/en/ABAPINTO_CLAUSE.htm#&ABAP_ALTERNATIVE_1@1@]).
- - Remove the CORRESPONDING, so quantity will fill the first field adqntp1. ([ref|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_WA.htm])
- - Then loop at the internal table and move the quantity when necessary to the 2 other fields.
* Fill the internal table
SELECT msehi adqntp
INTO TABLE internal table
FROM lipso2
WHERE vbeln = wrk_doc1
AND msehi IN ('KL','K15','MT').
* If required move the read quantity in the appropriate column.
LOOP AT internal_table ASSIGNING <fs>.
CASE <fs>-msehi.
WHEN 'K15'.
<fs>-adqnt2 = <fs>-adqnt1.
CLEAR <fs>-adqnt1.
WHEN 'MT'.
<fs>-adqnt3 = <fs>-adqnt1.
CLEAR <fs>-adqnt1.
ENDCASE.
ENDLOOP.
- You could also create another table with only fields msehi and adqntp and then collect ([ref|http://help.sap.com/abapdocu_70/en/ABAPCOLLECT.htm]) the data to another table.
Regards,
Raymond -
How to retrieve the procedure value and pass the value to a form field
How to retrieve the procedure value and pass the value to a form field?
Set property for the field and the value is the actual procedure/function.
Cheers -
How to retrieve data from domain(Value Range) of the table
hi
how to retrieve data from domain(Value Range) of the table
thanksHello,
You can try using the FM: DOMAIN_VALUE_GET TB_DOMAINVALUES_GET.
BR,
Suhas
Edited by: Suhas Saha on Mar 24, 2009 10:08 AM -
How to write the java program to retrieve the last 7 days dates
Hi,
I am having requirement that how to write the java program to retrieve the last 7 days dates. Please help me.
Regards,
AhamadIt needs any jar file.Of course!
I did using jscape.My program is running fine.But it
requires jar file.Which is licensed version.Maybe you should follow the link the the 'license' on the site I posted!
>
I have the doubt is apache provides jar file free
versionMaybe you should follow the link the the 'license' on the site I posted! -
How do I retrieve the last three months diary stuff as my iPad appears to have wiped the info off please help.
Check Settings > Mail, Contacts, Calendars > [scroll way down to] Sync Events ...
Set the time period as you wish.
Maybe you are looking for
-
Wish I didn't upgrade! and now I need help to figure out how to make it wor
I have a Windows XP Pro 2nd edition with IE ver 6.0.2 (but I normally use FireFox) I've never had any trouble with iTunes until iTunes "forced" me to upgrade my iTunes applicaiton to version 6 if I wanted to "purchase" music. (note to self: Purchase
-
I cant back up my iPhone, as it needs a password but my screen is broken and i cant put in a password, is there anyways around this situation
-
Daylight Saving Time off by one hour
Take a close look at the attached screenshots. Both cRIO and PC are synchronized to the same time server. Yet, there is 1 hour & 1 minute difference on PST8PDT, or "only" 1 minute difference on PST8. Is it a bug??? I notice the same thing in LabVIEW
-
What is the max HDD for my model iMac?
Hi I have a 2006 (last of the white plastic gen) iMac 24" 2.16GHz Intel Core Duo. Came with 1GB RAM, which I upgraded to the maximum possible of 3GB RAM. It also came with a 250GB HDD which I would like to upgrade. I know Apple won't do this and I ne
-
Please check actionsipt3 as not working
I am trying to convert a flash folio to actionscript 3 I will endevour to describe my timeline setup followed by the frame code that I cannot get to work. At the moment the time frame keeps looping, buttons and AC3 loader/ progress components. I feel