Request a sequence number

Hello!
I am really new in programming and with jsp...but I wonder if you could help me...
I am trying to make a web application that should give a sequence number to the user. It is like a document number reservation. I am using the autoincrement to make the format of the number. I mean the number should have 5 digits , so I want to add "0" to the autoincrement......But I do not know how to do it.....
Here you have my code:
<html>
<TITLE> Order Number Request</TITLE>
<FORM METHOD=POST ACTION="PeticionNumero.jsp">
Please, fill in your userid <INPUT TYPE=TEXT NAME="userid" SIZE=20>
<P><INPUT TYPE=SUBMIT VALUE="RequestNumber">
</FORM>
</BODY>
</HTML>
==============================
And the jsp code:
<%@ page import="java.util.*, java.sql.*, java.io.* ,java.lang.*,java.text.*" %>
<%
//Cargamos el driver
Class.forName("com.mysql.jdbc.Driver");
Connection con = null;
Statement stat = null;
PreparedStatement ps = null;
<HTML>
<BODY>
try {
     //establecemos la conexion con la base de datos
     con = DriverManager.getConnection("jdbc:mysql://localhost/Incidencia?user=nobody&password=nobody");
     stat = con.createStatement();
     ResultSet rs = null;
     String userid = request.getParameter("userid");
     //Comprobamos que el campo no sea nulo
     if (userid==null)
%>
<BR> User id is mandatory. Click here Back to repeat the request.
<%
     else
          //Consultamos la fecha
          java.util.Date dt = new java.util.Date();
          java.sql.Date sqlDate = new java.sql.Date(dt.getTime());
          //Miramos cual ha sido la ultima orden
          String sql1 = "SELECT LAST_INSERT_ID()";
          ResultSet r = stat.executeQuery(sql1);
          r.next();
          int resultado = Integer.parseInt(r.getString(1));
          int longitud = sql1.length();
          For ( int i=0, longitud<i<=5)
          int tmp;
          tmp = "tmp" +"0";
          int RequestNumber = "tmp" + "resultado";
          //Creamos el formato de nuestra orden
          String sql4= "INSERT RequestNumber SET UserId = '"+userid+"',date = '"+sqlDate+"',RequestId ='"+RequestNumber+"' ";
     catch(Exception excpt)
          out.println(excpt.getMessage());
%>
</BODY>
</HTML>

public String padOnRight( int number, int length, char withChar )
   String paddedNumber = String.valueOf( number );
   while( paddedNumber.length( ) < length )
      paddedNumber += withChar;
   return( paddedNumber );
public String padOnLeft( int number, int length, char withChar )
   String paddedNumber = String.valueOf( number );
   while( paddedNumber.length( ) < length )
      paddedNumber = withChar + paddedNumber;
   return( paddedNumber );
}You probably want to do this:
// Get int sequenceNumber from database
String numberToShowUser = padOnLeft( sequenceNumber, 5, '0' );
// Put it in the request, session, whatever, and show the user- Jesse

Similar Messages

  • Reading or changing sequence number in TCP packets

    I don't know wether this is feasible,But you're my last chance to figure out something else.Can i read the sequence number that comes inside the TCP header in the incomming packets?This sound illogical but since there is a method for getting the IP of the sender(And that IP exits in the IP header Network layer i),then the sequence number (TCP header inside the Transport layer)must exits in the packet.Can i read it?
    -And an even more illogical question? can i change that sequence number or the acknowlege number to form a new packet ? Its like converting a packet to and from a packet object to a string of bits ?
    I know excatly where the sequence and acknowledge numbers are located (after how many bits) inside the TCP header?

    ejp wrote:
    first off I'm wanna appply this to javame application and jpcap have some native code i dunno how to use it on a cell phone.You cant.You can migrate the code to work on a mobile phone, in theory. This is unlikely to be worth it even if you succeed.
    I was thinking if i can change the acknowledge numberYou can't.Like sticking your hand in a blender. Its simpler to say you can't but I say you shouldn't want to.
    i can order the server i'm connected to to send the data from a specific byte no sequentially.Use a protocol that already understands that. HTTP and FTP spring to mind.There are existing protocols for this which work and your phone is likely to support HTTP with XHTML basic already.
    -Drop this packet and then form another packet with the same info as if it were formed automatically except replaciong the acknolwedge number with the size of my buffered data + 1.TCP/IP will never let this work even if you could do it, which you can't. You cannot skip data this way. This is not what acknowledgements and sequence numbers are for.
    I also know that some protocols support requesting files from a specific byte(like HTTP) but i wanna do it inside the network layer not the application layerWhy?You prefer the blender, I see.

  • Enhancement Request: Recalculate Sequence Numbers

    Hi
    Wherever apex has sequence numbers (for branchs, items, regions etc.), please could we have the ability to recalculate them based on increments of ten so for example items as follows:
    P_ITEM1 - sequence = 1
    P_ITEM1 - sequence = 11
    P_ITEM1 - sequence = 12
    P_ITEM1 - sequence = 100
    P_ITEM1 - sequence = 120
    Would become:
    P_ITEM1 - sequence = 10
    P_ITEM1 - sequence = 20
    P_ITEM1 - sequence = 30
    P_ITEM1 - sequence = 40
    P_ITEM1 - sequence = 50
    The option to exclude items with a sequence number of 999 from the recalculation would also be handy. This can become a bit of a pain when a page has been updated many times and you end up with bunching of sequence number so that if something has to be inserted between them, you have to edit a number of items or whatever to make that happen.
    If you could do a page-wide or application-wide recalculation - t'would also be cool.
    If this feature is available already, please point me to it.
    Cheers
    Ben

    The Cleanup feature Paul mentioned is new in 4.0 but fyi in any version component sequence numbers accept non-integer values so you can always insert something anywhere without a need to resequence...Thanks! I never knew that! Oh yes. And they can be negative too. We have some very esoteric looking sequences...
    Actually the decimals are pretty useful for things like conditional display of regions. If you've got 3 related but mutually exclusive regions, numbering them 20.1, 20.2, and 20.3 indicates the relationship between them. Which brings me to another enhancement request: regions to have separate name and title properties (like pages do), so that where such regions have to have the same title shown to users, it's a lot easier for developers to tell them apart.

  • Sequence Number on Labels

    Hope someone can help.  I have a request from client to print a sequential number on an avery label.  For example, if i used address labels that were 30 to a page, the first label would have 1 and the second label would have 2, etc.   No data is being printed so i don't have a table,  just the seq number.  Am i missing something easy here or can it not be done in crystal 2008.
    Thanks for any help or suggestions.
    Jeff

    Jeff,
    There's no reason to use Access, Excel, or any other outside application. A just about any modern database will support the use of temporary tables... and that's all you need.
    If your report is built be using linked tables, add the following code as a SQL Command (tested in SQL Server)
    DECLARE @SeqNum INT, @MaxValue INT;
    SET @SeqNum = 1
    SET @MaxValue = (SELECT MAX(SequenceNumber) FROM TableName)
    IF object_id('tempdb..#MyTempTable') IS NOT NULL
    BEGIN
       DROP TABLE #MyTempTable
    END
    CREATE TABLE #MyTempTable (SeqNum INT)
    WHILE @SeqNum < @MaxValue
    BEGIN
         INSERT INTO #MyTempTable (SeqNum) Values (@SeqNum)
         SET @SeqNum = @SeqNum + 1
    END
    SELECT SeqNum FROM #MyTempTable
    1) Be sure to alter line 3 of the code, where is says set @MaxValue = , so that  it is pulling the maximum sequence number from your table... This will make sure the proper number of rows are created... Not too many, not too few.
    2) Link this back to your table using an LEFT OUTER JOIN... With the new command on the left side.
    -- If you are already using a command to pull your data, just add this code to the existing command and reference the #MyTempTable in the main select statement.
    HTH,
    Jason

  • How to pass the sequence number of current loop in a for loop in FPGA vi to the host

    PCI-7830R
    LV 8.2
    What I was trying to do is to use multiple DIO to generate pulse at different sequence. Mode one is to automatically sweep from DIO1 to DIO20; mode 2 is several DIOs generate pulse simoutaneously.  So I use a case structure to make the selection, in the mean time, I set up two for loop in each case so that I can use multiple pulse generations. For example, in scanning mode, if I set 2 exposures, it sweeps from 1 to 20 then do it again.  
    Then I need to get the loop sequence number, i of each scenario. So I put an indicator within the first loop, and create a local variable of it and put in the second one.  Running the FPGA vi alone, I can see the indicator change in each case from 0 to N-1, N being the for loop time.But in the host vi, I tried to add this indicator as an element in the read/write invoke method, in the debugging mode, I could only see it directly jump to N-1 without all the changes I saw in FPGA vi. 
    Is it possible to get this number passed correctly from FPGA vi to the host vi? Thanks

    Thanks for the reply Jared.
    Excuse me if it looks incorrect, but I'm new to FPGA programming, so I would have to look into the FIFO you referred to.  I used local variables because for one thing I have several different cases containing for loop in each of them, and I only want one indicator for the "i".  If I put the indicator out of any for loop, it's only gonna show the last number which is N-1.  For the other thing, it seems like property nodes are not allowed in FPGA vi.  And by doing this, I can see the i number changing from 0 to N-1 in each case, well, in FPGA vi's front panel.  But while I ran the host vi with everything, the indicator in host vi's front panel only showed the last number N-1. It may be the reason you said, it happened too fast before the indicator in host vi can catch it.
    What I want to realize is to group the data I collect in host vi, for example, when I choose multiple exposure in each mode, and the FPGA runs 1 through 20 then do it again, I want the data stored in two groups using the loop sequence number as the seperator in file name.  So it goes like 1-1, 2-1.......20-1; then 1-2, 2-2,.....20-2.

  • Need to query the database to get the last sequence number

    Hi all
    I am trying to get the last sequence number of the last row inserted into my Oracle database. Please could someone give me the SQL which would allow me to do this - using Oracle SQL Explorer I have confirmed that there is a sequence on the table which is called: XYZ_SEQ and the code for this is:
    CREATE SEQUENCE "MY_USER_NAME"."XYZ_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 NOORDER NOCYCLE ;
    My Java application is inserting a row into my table and to insert a new row I need to have the last sequence inserted +1 so the new row can be added.
    Any help would be much appreciated.

    Hi,
    Welcome to the forum!
    If you are using a sequence just do (example):
    INSERT INTO TABLE_NAME
       (COL1,
        COL2)
    VALUES
       (SEQUENCE_NAME.NEXTVAL,
        OTHER_VALUE);to obtain (and use) the next number in the sequence when you are inserting.
    If you have a sequence to use for a specific table, you should use it when your insert new data (no matter your are doing that: java application, procedure, etc). Doing this you avoid some problems when you have the sequence 'out of date' about the associated data.
    Regards,
    Edited by: Walter Fernández on Sep 19, 2009 10:08 AM
    Edited by: Walter Fernández on Sep 19, 2009 10:10 AM

  • Portal Master-detail form how to auto assign detail record sequence number

    Portal Master-detail form how to auto assign detail record sequence number.Please help me?

    You can just read the following section
    Can I specify a sequence number generator as the default value for a form column?
    Yes. Enter the following in the "default value" field for the column:
    #<schema name>.<sequence name>.nextval
    where <schema name> is the name of the schema containing the sequence, and <sequence name> is the name of the sequence. The entry is preceded by a "#".
    For example, if the schema name is "SCOTT", and the sequence name is "CUSTOMER_SEQ", the default value entry is:
    #SCOTT.CUSTOMER_SEQ.NEXTVAL
    same way you can do for master - detail form.
    for more information on forms please refer the following URL.
    http://otn.oracle.com/products/iportal/htdocs/portal_faq.htm#BuildingApplications
    hope it helps.

  • File sequence  number in a Flat file

    Hi,
    I am working on Idoc to file scenario wherein my output file will have a sequence number assigned to each level.
    there are 4 levels and hence 4 sequence number to be genearted and its values should also have the same sequence number.
    i am doing this just by using Counter function.
    But when i am getting  a multiple detail records, for each detail record(0040) level its keep incrementing.but it should have the same value what its level has.
    for ex:
    ALPHAMER AS2 E5 710 20114806124829 01.00   
    0000 00000000 20100102 V3.0 SORD CZ1
    0010 00000001 76767 123 100 WER Constant BNG 560011 RAJ WERR     560011    BTM   X EN RT
    0020 00000001 TYUIOP
    0040 00000001 8765 6532 200 45 10 WE 20 AG
    0040 00000002 8765 6532 200 45 10 WE 20 AG
    0040 00000003 8765 6532 200 45 10 WE 20 AG
    0040 00000004 8765 6532 200 45 10 WE 20 AG
    9999 99999999
    It has to be like this.
    ALPHAMER AS2 E5 710 20114806124829 01.00   
    0000 00000000 20100102 V3.0 SORD CZ1
    0010 00000001 76767 123 100 WER Constant BNG 560011 RAJ WERR     560011    BTM   X EN RT
    0020 00000001 TYUIOP
    0040 00000001 8765 6532 200 45 10 WE 20 AG
    0040 00000001 8765 6532 200 45 10 WE 20 AG
    0040 00000001 8765 6532 200 45 10 WE 20 AG
    0040 00000001 8765 6532 200 45 10 WE 20 AG
    9999 99999999
    Can someone help me in achieving this.
    Regards

    Hi there,
    Just to try out from a different view, the following case could be implemented if the pre-requiisites are satisfied:
    Pre-requisites:
    1) The element that carries a primary factor, let us say, '8765' from your example.
    2) Functionally there is an element in your header item that relates the line items under it.
    My understanding of your example:
    1) Line items present for 00, 10, 40
    2) Line item 30 absent in the series
    Proposal:
    Map source field (the one that is arelating factor, here the one that carries '8765') -> INDEX (start by 0, increment by 1) -> multiply by one.
    INDEX standard function property: Donot Reset for every context;
    Srikanth Srinivasan
    Edited by: Srikanth Srinivasan on Jan 10, 2011 11:02 AM

  • Error While Generating Sequence Number. Contact your system Administrator

    Hi All,
    I have developed a form to provide our client with 'an easy to fill' User Interface. This form will be used instead of the standard form present in Business Suite.
    Some columns of the table, on which form is based, are getting populated via generation of sequence numbers.
    Now the problem is, after deploying custom form developed by me in the instance, Standard form is showing this error
    " Error While Generating the Sequence Number. Please contact the System Administrator "
    I am unable to trace why this error had started appearing..
    Any suggestions would be of great help...
    Thanks in Advance,..

    Forms version 6i,
    Database version 9.2.0.6.0
    Sequences which I am using are used there in Standard form also..
    So evrytime i need to save the record, I am selecting NEXTVAL of it into
    the respective item of the datablock..

  • How to populate sequence number automatically in fusion web application

    Hi all,
    I created simple fusion web application.
    I created a form which has programid and remaining fields are there.
    If i press save button program details will save in database.
    here i am giving programid manually. but i need to generate a sequence number to programid automatically.
    If i give program details and save for this program details one sequence number should be generate and save in databasePlease help me
    Thanks,
    raj

    Here there are two methods given
    1. Generating sequence number from the trigger
    2. another one is from java class.
    I tried two but i am not getting the sequence number.
    In my application under model project i have programview.
    i created CustomEntityEmpl java class.
    I double clicked on programid in attributes window, given some sequence name in name field,given db sequence name as as value.
    i mentioned name of sequence in Java class. but still it is asking a value when submiting the program details with out program id.
    please help ASAP
    Thanks
    Nag

  • Sequence number in process order

    Hi,
    Kindly brief about usage of sequence number, which is in process order with example. Is this can be used for capacity leveling. If so how that can be done.
    If one sequence number is assigned to multiple process orders means double entries, then what is the impact during capacity leveling based sequence number.
    Is number range is maintained any where in SPRO for sequence number. If so where? Is there any possibility to maintain number range for sequence number if required?
    Thanks & Regards,
    N. Laxman

    1.Seq. number in an order
    Number that can be assigned to production orders or planned orders at the level of the task list header and is therefore valid for all the operations in an order.
    The sequence number is used to  sort the orders for the display on the planning table and to
    form a dispatching sequence using the sort key.
    3.

  • Batch rename with minimum numeber of digits in sequence number

    I'm pretty sure I remember this working how I wanted in previous versions of Bridge, but at least since cs4, it has not worked as I would like. I've tried searching for an answer or a setting that I'm missing, but have come back empty-handed.
    Here's my situation. Let's say I'm renaming 18 files. Each file has a sequence number. I want the sequence numeber for the first 9 to be one digit, and for the second nine to be 2 digits.
    i.e. image_1.jpg, image_2.jgp, image_3.jpg...image_10.jpg, image_11.jpg...
    The best way I've found that I can do this is to select all 18 images, and assign a 2-digit sequence number. Then, once that is complete, select the first 9 and repeat, but with a 1 digit number.
    In the past, I could select all 18 images, and choose a 1 digit number, and after 9, it would switch to 10, instead of going back to zero. Is there still a way to do that? I know it's only one extra step, but that one extra step is actually kind of two, because each time I have to reset tho starting number back to 1 or 10, and switch the setting from 2-digits to 1-digit and back again. And I usually have to rename multiple groups of files at once, so it does add up. Granted, much better than renaming one at a time, but not as convenient as I feel it could be, and as it once was.
    Am I missing something?
    Thanks,
    iLan

    While I certainly can understand the way in which computers work, I also understand that in a program as complex as any of the components in Adobe's Creative Suite, there is most certainly a way to override the computer's numerical logic so that it can remove the initial "0" from a 2-digit number. Granted, that may not be possible in the current version of Bridge, theoretically it is "Possible". And I'm quite sure it functioned that way in previous versions, although I really don't know which version I was using when it worked that way. Maybe cs2?
    As a developer, the whole reason for this question is to avoid having to create extra code in my applications to add an unnecessary "0" to digits 0-9 in any filenames of any files I want to load. Although it looks as though adobe changed the default behavior of the batch rename function, and removed (or in some peoples' minds improved) some functionality without an option to get it back.
    Unfortunately for me anyways...
    Thanks for the help,
    ilan

  • Error in mail sender channel : invalid sequence number

    Hello all,
    I'm having the following issue.
    I'm using the mail adapter to get messages from a mail server, which are attached to the mail.
    This interface is already productive, and is working fine most of the time.
    Only frequently I get the following error, which can be found in the java log.
    exception caught during processing mail message[630];
    java.io.IOException: the specified message not found: -ERR invalid sequence
    number
    This error seems only to appear when there are a lot of mails to be fetched.
    All the mail is read into PI and processed succesfully, only I also get a lot these errors.
    Does anyone know what causes this error?
    I also don't know where this sequence number is coming from, and what's the meaning of this.
    Is it possible it's trying to read the same mail more then once?
    The settings in the mail sender channel are:
    - transport protocol : POP3
    - message protocol : XIPAYLOAD
    - Use mail package : enabled
    - content encoding : none
    - Keep attachments : enabled
    - QOS : exactly once
    - Set adapter specific message attibutes : enabled
    The PI version is 7.01
    Thanks a lot in advance for the replies on this question.
    Kind regards,
    Marco van Iersel

    Hi
    Well we have used it with POP3 and it is working in the way as it should be.
    This feature is recommended  by sap when the number of emails to be read is large.
    You can set this additional parameter to restrict the number of mails fetched by sender mail adapter in one polling interval.
    Sometimes the mailbox configured for the sender mail adapter contains large number of unread mails, which exceeds the average expected number of mails in one polling interval. In such a case, processing of all the unread mails in the same polling interval by sender mail adapter degrades the system performance. To avoid this, set value of this parameter to the maximum number of mails to be fetched and processed in one polling interval. The remaining mails exceeding the limit would be processed in the next polling interval.
    That's why I have asked you to give it a try.

  • System Extract - Incrementing a sequence number in detail record layout

    I have a system extract for a bank that requires a file header, batch header, detail, batch trailer and file trailer record. The detail record is at the run result level as I am looking to choose all records for a particular deduction (savings bonds) and I also have to put employee ssn and full name. This is working fine. I also have to put a sequence number, ie. detail record layout is record type, length 2, string, record sequence number, 5, ?????, employee SSN, length 9, field, employee full name, length 9, field. I need to increment the record sequence number by one for each detail record in the file. Ie. detail record 1 has record sequence number of 00001, detail record 2 has record sequence number of 00002.
    What type of data element would I set up? For this particular field, I don't need to go against a database field, I only need to keep track of the previous record's sequence number so that I can keep incrementing by 1 until all detail records have been written. The batch trailer has a record count of the number of detail lines and that works fine because I've set that up as a type 'total' with a 'count' of the detail records. I also have in the batch trailer a sum of the pay values from each of the detail records and that works fine as subtrailers allow total data elements where detail records do not.

    You can use any of the below mentioned 2 options in the ctl (Control) file:
    1. SEQUENCE(1,1)
    2. "xxcust_autoinv_seq.nextval"
    where xxcust_autoinv_seq is a database sequence.
    Thanks,
    Angelica.

  • Daily sequence number

    Hi,
    I need a clean solution for a daily sequence number (starts from 1 everyday). Clean in the sense that upon initial setup, I do not have to do anything and I can get my number everyday by just one jdbc call/query.
    Thank you in advance.

    What is the business justification for this requirement? Normally, you should just use a regular non-resetting sequence. If users want to see a "pretty" sequence number, simply generate something for them when you query the data using the row_number, rank, or dense_rank analytic functions. If users want to see sequences reset, they probably also want to see gap-free sequences, which is not something that you can ever guarantee in a scalable system where multiple users are allowed, though you can present gap-free sequences of values at query time.
    You can have a job that either drops and recreates the sequence every day or that goes through some logic to reset the sequence to 1 by changing the increment. This gets rather hairy, though, because the job will fail (or fail to run) on occasion and requires that no one be processing data at the time.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • Pdf files will not open

    Hi, I have viewed through this forum and did not find a problem with similar symptoms. I upgraded from Adobe Reader 8 to Reader 9 and then the .pdf files will not open. Actions and Observations/Symptoms: 1)  After I clicked onto the pdf document icon

  • Layout and file description doesnot match

    In Profit center planning, When I am press the overview button after entering the account numbers , version and all other details in the selection criteria, Then I get this error Layout and file description doesnot match. I went back and I deleted th

  • Errors using IMAQ PCI-1409

    I'm getting an error when running a fairly basic VI to acquire a sequence from the PCI-1409 card. It is -1074397110 Exhausted resources (general). It's occurring in the 'generate pulse' bit. As far as resources go, the number of buffers in MAX is sti

  • I can't watch video on my mac book pro

    I have a new Mac Book Pro and am new to Mac in general.  You Tube for example tells me I need adobe flash player, but when i download adobe flash player it asks for a password but won't accept my Apple ID password.  How do I fix this?  I remember not

  • Satellite Internet Issues

    Just so Adobe Help knows what is going on in my part of the "Wonderful Web" I have slow and inconsistent service due to the satellite issues so the only way to download a 700 MB program is off a disk or stick ... so as far as getting the program to l