Sorry for the poor formatting of my email, here it is again as plain
text, much more pleasant to read.
I am starting to use Update in JDB for the first time and I ran into a
problem.
load 'data/jdb'
hf=: Open_jdb_ 'J:\databases\jdb'
hd=: Create__hf 'sampledb'
NB. We make a table with a unique column i.10000, and another column all
zeros.
Create__hd 'table';'uniquecol int;othercol int'
+-+
|4|
+-+
Insert__hd 'table';< (i.10000);(10000$0)
Read__hd 'count othercol from table'
+--------+-----+
|othercol|10000|
+--------+-----+
NB. We can update 100 records just fine
update100=: (<'table')&,"0 <"1 ,&(<'othercol')"1 (1&;)"0
'uniquecol='&,@": each <"0 i.100
Update__hd"1 update100
NB. Once we go over 2125 updates, an allocation error occurs (when I
first discovered this error, it was actually occurring consistently at
3125 updates, no clue why).
update3000=: (<'table')&,"0 <"1 ,&(<'othercol')"1 (1&;)"0
'uniquecol='&,@": each <"0 i.3000
Update__hd"1 update3000
|allocation error: tinsert
| autoid =:autoid,>0{Tinsert
Read__hd 'updated: sum othercol from table'
+-------+----+
|updated|2025|
+-------+----+
NB. The 2025th record can no longer be read (it is deleted in the active
record mask d0, but the updated version was not added).
Read__hd '* from table where uniquecol=2025'
+---------++
|uniquecol||
+---------++
|othercol ||
+---------++
Read__hd 'count othercol from table'
+--------+----+
|othercol|9999|
+--------+----+
Any ideas?
Also, is there a better way to apply a large number of updates in JDB
(not using "1, just as a single update)?
BTW I'm creating columns in referenced tables and then updating them to
values from commonly-used aggregate queries from their referencing
tables so that I can access these aggregations more quickly. This way
applications built on JDB which tend to ask the same kinds of questions
many times will run instantaneously instead of with significant delays.
Not sure if any other JDBers would use it, but certainly a helpful trick
for my applications.
Jordan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm