prob.. in the increasing of sring values..


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: prob.. in the increasing of sring values..

  1. #1
    Join Date
    Nov 2004
    Posts
    29

    prob.. in the increasing of sring values..

    i have the following query which insert Voucher No. that is string like that BP0101001..

    when i insert voucher no it select maximum voucher no. from database and then increase the voucher no by 1..i.e. its incresing the voucher no..automatically by taking voucher no from the database..

    It increases like that...

    BP0101001
    BP0101002
    BP0101003
    BP0101004


    but its coming error of:

    Exception:[Oracle][ODBC][Ora]ORA-01401: inserted value too large for column

    as i have already checked the insertion of all the vales size..its with in the size of database..

    is there an prob.. in my following query..

    plz.. make my query working for me...

    Statement stmt=conn.createStatement();

    stmt.execute("SELECT max(vou_no) as max_id FROM pay_header ");

    results = stmt.getResultSet();

    if(results.next())
    {
    Voucher_No=results.getString("max_id") + 1;
    }
    conn.setAutoCommit(false);

    PreparedStatement pstmt = conn.prepareStatement(
    ("INSERT INTO pay_header VALUES (?)"));

    pstmt.setString(1,Voucher_No);

    pstmt.executeUpdate();

    conn.commit();
    conn.setAutoCommit(true);

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    When you do this:

    stmt.execute("SELECT max(vou_no) as max_id FROM pay_header ");

    and retrieve like this:

    Voucher_No=results.getString("max_id") + 1;

    ..ir appears to me that you are attaempting to retrieve an int/long as a string. (??)

    I haven't worked w. Oracle in ages but code like that have always bugged out for me....

    Apart from that it seems like you are updating the wrong table column.
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center