1. edbi error 1046

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?

new topic     » topic index » view message » categorize

2. Re: edbi error 1046

What driver are you using?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

3. Re: edbi error 1046

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: edbi error 1046

jeremy said...

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!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu