|
-
Sep 28th, 2002, 02:10 PM
#1
Thread Starter
Addicted Member
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
-
Sep 28th, 2002, 02:14 PM
#2
New Member
A little clearer please
I do not know what you want to do. Are you talking about field names or sizes, values or what?
-
Sep 28th, 2002, 02:24 PM
#3
Thread Starter
Addicted Member
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,
-
Sep 28th, 2002, 02:30 PM
#4
Fanatic Member
If using MS ACCESS put the Field property to AUTONUMBER!
-
Sep 28th, 2002, 02:33 PM
#5
Thread Starter
Addicted Member
-
Sep 28th, 2002, 02:41 PM
#6
Fanatic Member
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
-
Sep 28th, 2002, 02:42 PM
#7
New Member
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
-
Sep 28th, 2002, 02:48 PM
#8
Thread Starter
Addicted Member
Re: What database are you using
Sorry, I must have mentiond that in advance, I am using MS jet engine through VB
-
Sep 28th, 2002, 02:50 PM
#9
Fanatic Member
JET ENGINE! Then my method will work out perfectly!
-
Sep 29th, 2002, 01:05 PM
#10
Thread Starter
Addicted Member
Thanks but How do I do it from inside a program?
-
Sep 29th, 2002, 01:09 PM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|