1. edbi error 1046
- Posted by euphoric (admin) Aug 06, 2011
- 1115 views
I've got this code:
public function get_solitaire_sets() sequence sets = {} edbi:dbr_handle res = edbi:query_rows("select solitaire_set_name from solitaire_sets") if atom(res) then puts(1,"\nEDBI Error: " & error_message( res ) ) else for t=1 to length(res) do sets = append(sets,res[t][1]) end for end if return sets end function
The variable res ends up being 1046. This crashes error_message(). Anybody know what's up with that?
2. Re: edbi error 1046
- Posted by jeremy (admin) Aug 06, 2011
- 1087 views
What driver are you using?
Jeremy
3. Re: edbi error 1046
- Posted by jeremy (admin) Aug 06, 2011
- 1120 views
BTW... your real problem is probably that you need to send the database handle to the error_message routine. It's signature is:
public function error_code(db_handle h = 0)
If you only have one database handle open, you can simply omit the db_handle parameter, the opened handle will be used automatically. Thus your code would look like:
public function get_solitaire_sets() sequence sets = {} edbi:dbr_handle res = edbi:query_rows("select solitaire_set_name from solitaire_sets") if atom(res) then puts(1,"\nEDBI Error: " & error_message() ) else for t=1 to length(res) do sets = append(sets,res[t][1]) end for end if return sets end function
However, a better function may be to use next since you are building another sequence with it. The above has repeitive loops and memory consumption. query_rows first calls query, then loops through all the results appending to a sequence. It then returns a sequence that you in turn loop through. Better would be something like:
public function get_solitaire_sets() sequence sets = {} dbr_handle dbr = query("select solitaire_set_name from solitaire_sets") if error_code() then puts(1, "\nEDBI Error: " & error_message()) else while sequence(o) with entry do sets = append(sets,o[1]) entry object o = edbi:next(dbr) end while closeq(dbr) end if return sets end function
Jeremy
4. Re: edbi error 1046
- Posted by euphoric (admin) Aug 06, 2011
- 1166 views
BTW... your real problem is probably that you need to send the database handle to the error_message routine.
Yes, that was a problem! :/
I'll try your improved function as well.
Thank you!