Results 1 to 11 of 11

Thread: SQL Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    175

    SQL Question

    Hi all,

    Is there anyway to increase a field reapitedly? I meam, say we have a blabnk field and we want to increase all the fields by 1 so the first field will be =1, second =2 thired =3 and so on.

    Thanks in advance
    Mass

  2. #2
    New Member
    Join Date
    Sep 2002
    Location
    Orlando, FL
    Posts
    5

    A little clearer please

    I do not know what you want to do. Are you talking about field names or sizes, values or what?
    Bob Robey

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    175
    values, as I mentiond, If The firat field is 1 the same field in the second record becomes 2 and so on

    I Hope I'm clear,
    Mass

  4. #4
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    If using MS ACCESS put the Field property to AUTONUMBER!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    175
    How do I do that?
    Mass

  6. #6
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    1) OPEN MS ACCESS
    2) SELECT YOUR TABLE
    3) PRESS DESIGN BUTTON ON THE RIGHT HAND SIDE
    4) CHANGE THE DATATYPE OF YOUR DESIRED FIELD TO SUTONUMBER
    5) SAVE YOUR DATABASE
    6) CLOSE IT

    THATS IT :d

    KINJAL

  7. #7
    New Member
    Join Date
    Sep 2002
    Location
    Orlando, FL
    Posts
    5

    What database are you using

    If you are using oracle look up sequences they accomplish the same as autonumber in MSAccess
    intRecNum = select sequencename.next from dual;
    will give you the next sequence number.
    I am sure tha sql server has an appropriate routine to do that also.
    The danger of using sequences is that if you ever lose your database content and restore it all sequences will have to be reset to that largest value that it contained at the time of failure.
    Another way to do it would be to create your own class and a db table tblSeqVal and keep a number in it. You can create methods .next, .first, .last, etc and then go to your
    own "autonumber or sequencer. That way if you db crashes the restore will also restore your sequence table.

    Table definition

    create table tblSeqVal as (
    intSeqField number(5));

    next could be

    define sequence table class

    Public Function next () As Integer

    db definition/connection stuff

    intRecNum = select max(intSeqField + 1) from tblSeqVal;

    End Function

    Hope this helps
    Regards
    Bob Robey

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    175

    Re: What database are you using

    Sorry, I must have mentiond that in advance, I am using MS jet engine through VB
    Mass

  9. #9
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    JET ENGINE! Then my method will work out perfectly!

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    175
    Thanks but How do I do it from inside a program?
    Mass

  11. #11
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Just don't provide a value for that field when inserting a new record. The DB will value it automatically.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width