I have a function that finds an oid from a field in a table. According to the docs, the oid field is automatically created and auto incremented. Sounds great.
def teddy_bear_id_by_url(url)
query = "select oid from teddy_bears where url = \"#{url}\""
res = $db.execute(query)
return res
end
Unfortunately this code returns a [] (empty array), when running the query in the sqlite shell gives a ‘good’ value (e.g. 4).
def teddy_bear_id_by_url(url)
return $db.execute("select oid from teddy_bears where url = '?'", url)
end
The above doesn’t work either.
I did indeed check that urlcontains what I think it does.
What might be happening?
There’s probably something funny going on in your
urlthat, combined with your string interpolation, is messing up your SQL. Your best bet is to use placeholders with yourexecutecall: