Re: EDS:: select or create table

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
K_D_R said...

I am having a wreck of a heck of a time trying to figure out how to create a database after db_table_list returns and a NO_TABLE error.

If the db has a table there is no problem. But if there is no table everything freezes up pronto.

There's a lot of stuff in there that I don't recognize, like key_gets(). Are you sure that answer is taking the value that you think it is? Can you be more specific about what "freezes up" means?

Matt

Key_gets was not the problem. The routine was freezing up after displaying "Select Table" on the top-line with the cursor blinking, but not accepting any keyboard input. It should have accepted the name of a table typed in by the user. The following routine works. The question now is why does the code testing dttblst for atom status and "NO_TABLE" status fail? What is the proper use of NO_TABLE?

procedure select_or_create_table() 
    db_banner("Select Table") 
    sequence answer = {} 
--  tmp = {} 
    tables = {} 
    object dbtblst 
    dbtblst = db_table_list() 
--    if atom(dbtblst) then 
--          if dbtblst = NO_TABLE then 
--              answer = delete_trailing_white(key_gets(" ", {})) 
--          end if 
--  else 
--          for i = 1 to length(dbtblst) do 
--              tables = update_history(tables, sprintf("%s", {dbtblst[i]})) 
--          end for 
--          answer = delete_trailing_white(key_gets("", tables)) 
--   
--  end if 
 
    if length(dbtblst) < 1  then 
	answer = delete_trailing_white(key_gets("",{})) 
    else 
	    for i = 1 to length(dbtblst) do 
		tables = update_history(tables, sprintf("%s", {dbtblst[i]})) 
	    end for 
	    answer = delete_trailing_white(key_gets("", tables)) 
    end if 
     
     
    if length(answer) != 0 then 
	if db_select_table(answer)!= DB_OK then 
	    if db_create_table(answer) != DB_OK then 
		db_banner("tb") 
		any_key("Failed to create/select table! ") 
	    end if 
	end if 
	tables = update_history(tables, answer) 
    end if 
end procedure 

Your assistance is appreciated.

Kenneth Rhodes

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

Search



Quick Links

User menu

Not signed in.

Misc Menu