Re: EDS: bad record number.

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu