0

How I can assign a sequence value to a field "UID" which is NUll in existing sqlite table, for example

table: FOO  
name    UID
A   1
B   2
C   100
D   NULL
E   NULL
F   NULL

what I want is

table: FOO  
name    UID
A   1
B   2
C   100
D   101
E   102
F   103

Can some body help? I want to seek an alternative for using autoincrement on my own reason...

thanks!

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
K. C
  • 735
  • 2
  • 8
  • 25

1 Answers1

0

Register a function that returns the number of times it's called, and then do

UPDATE FOO SET UID = 100 + increment() WHERE UID IS NULL
dan04
  • 87,747
  • 23
  • 163
  • 198
  • thanks, should increment() be a C function,or can it be python function? Or, can SQL language such as SELECT count(*) from FOO works instead of increment() ? – K. C Jun 13 '10 at 09:01