1. EDS: bad record number.
- Posted by aLays <alays at art-hack.ru> Feb 05, 2007
- 543 views
Hello, ALL I'm developed a news engine. To show news i'm use this code:
news_size = db_table_size() for i = 1 to news_size do title = db_record_key(i) record = db_record_data(i) put_item(record, title, i) end for
and got the error: bad record number. variables: news_size = 20 i = 2 e.g. 'for' code executed only one count base created with this code:
if db_create("news.ah", DB_LOCK_NO) != DB_OK then puts(1, "can't create news.ah") abort(-1) end if if db_create_table("news") != DB_OK then puts(1, "can't create table _news in news.ah") abort(-1) end if for i = 1 to 20 do -- insert with random key, for debug only if db_insert(sprintf("%8d", rand(999999)),{"04.02.2007", "Crazy Coder", "Some text", "http://www.art-hack.ru"}) != DB_OK then puts(1, "can't insert initial record") end if end for db_close()
How to fix this error? Best Regards, Crazy Coder(webmaster at art-hack.ru)
2. Re: EDS: bad record number.
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 05, 2007
- 530 views
aLays wrote: > > Hello, ALL > > I'm developed a news engine. > To show news i'm use this code: > > }}} <eucode> > news_size = db_table_size() > > for i = 1 to news_size do > title = db_record_key(i) > record = db_record_data(i) > put_item(record, title, i) > end for > </eucode> {{{ > and got the error: bad record number. > variables: > news_size = 20 > i = 2 > This seems to work for me. Are you sure there is nothing in between the "db_table_size()" call and the start of the 'for' statement? Here is the code I used. ...
include database.e procedure put_item(sequence pRec, sequence pTitle, integer pN) printf(1, "Record: #%d ", pN) printf(1, " Title: %s\n", {pTitle}) printf(1, " Data: '%s' '%s' '%s' '%s'\n\n", pRec) end procedure system("del news.ah", 2) if db_create("news.ah", DB_LOCK_NO) != DB_OK then puts(1, "can't create news.ah") abort(-1) end if if db_create_table("news") != DB_OK then puts(1, "can't create table _news in news.ah") abort(-1) end if if db_select_table("news") then end if for i = 1 to 20 do -- insert with random key, for debug only if db_insert(sprintf("%8d", rand(999999)),{"04.02.2007", "Crazy Coder", "Some text", "http://www.art-hack.ru"}) != DB_OK then puts(1, "can't insert initial record") end if end for db_close() integer news_size sequence title sequence record if db_open("news.ah", DB_LOCK_NO) = DB_OK then if db_select_table("news") then end if news_size = db_table_size() for i = 1 to news_size do title = db_record_key(i) record = db_record_data(i) put_item(record, title, i) end for end if
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: EDS: bad record number.
- Posted by aLays <alays at art-hack.ru> Feb 05, 2007
- 529 views
Derek Parnell wrote: > > aLays wrote: > > > > Hello, ALL > > > > I'm developed a news engine. > > To show news i'm use this code: > > > > }}} <eucode> > > news_size = db_table_size() > > > > for i = 1 to news_size do > > title = db_record_key(i) > > record = db_record_data(i) > > put_item(record, title, i) > > end for > > </eucode> {{{ > > and got the error: bad record number. > > variables: > > news_size = 20 > > i = 2 > > > > This seems to work for me. Are you sure there is nothing in between the > "db_table_size()" > call and the start of the 'for' statement? > > Here is the code I used. ... > > }}} <eucode> > include database.e > > procedure put_item(sequence pRec, sequence pTitle, integer pN) > printf(1, "Record: #%d ", pN) > printf(1, " Title: %s\n", {pTitle}) > printf(1, " Data: '%s' '%s' '%s' '%s'\n\n", pRec) > end procedure > > system("del news.ah", 2) > if db_create("news.ah", DB_LOCK_NO) != DB_OK then > puts(1, "can't create news.ah") > abort(-1) > end if > > if db_create_table("news") != DB_OK then > puts(1, "can't create table _news in news.ah") > abort(-1) > end if > > if db_select_table("news") then end if > for i = 1 to 20 do > -- insert with random key, for debug only > if db_insert(sprintf("%8d", rand(999999)),{"04.02.2007", "Crazy Coder", > "Some text", "http://www.art-hack.ru"}) != DB_OK then > puts(1, "can't insert initial record") > end if > end for > db_close() > > integer news_size > sequence title > sequence record > > if db_open("news.ah", DB_LOCK_NO) = DB_OK then > if db_select_table("news") then end if > news_size = db_table_size() > > for i = 1 to news_size do > title = db_record_key(i) > record = db_record_data(i) > put_item(record, title, i) > end for > end if > </eucode> {{{ > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell Thanks, i'm running you program full, it's work. But when i'm splitted it(create base in install program, output in engine), i'm also got same error. Install script:
procedure make_news_base() if db_create("news.ah", DB_LOCK_NO) != DB_OK then puts(1, "can't create news.ah") abort(-1) end if if db_create_table("news") != DB_OK then puts(1, "can't create table _news in news.ah") abort(-1) end if if db_select_table("news") then end if for i = 1 to 20 do -- insert with random key, for debug only if db_insert(sprintf("%8d", rand(999999)),{"04.02.2007", "Crazy Coder", "Some text", "http://www.art-hack.ru"}) != DB_OK then puts(1, "can't insert initial record") end if end for db_close() end procedure
Show script:
global procedure execute_news(sequence params) integer news_size sequence title sequence record securitylab_news() -- not effect(don't use db) puts(1, "<p><h1>news</h1><hr>\n") if db_open("news.ah", DB_LOCK_NO) = DB_OK then if db_select_table("news") then end if news_size = db_table_size() for i = 1 to news_size do title = db_record_key(i) record = db_record_data(i) put_item(record, title, i) end for end if puts(1, "</p>") db_close() end procedure
4. Re: EDS: bad record number.
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 05, 2007
- 532 views
Ok, does the put_item() routine select a different table or delete anything from the "news" table? Can you show us the put_item code? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
5. Re: EDS: bad record number.
- Posted by aLays <alays at art-hack.ru> Feb 05, 2007
- 526 views
Derek Parnell wrote: > > Ok, does the put_item() routine select a different table or delete anything > from the "news" table? Can you show us the put_item code? > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell Oh, yes. I'm stupid. put_item douse not affect to table, but from it i'm call procedure that open another base=) Big thank's. Theme closed.