[asterisk-users] Return variables from func_odbc calls?

Tilghman Lesher tilghman at meg.abyt.es
Wed Jan 26 03:56:08 CST 2011


On Wednesday 26 January 2011 03:02:19 Sherwood McGowan wrote:
> This is primarily aimed at Sir Lesher, whose name graces the source
> code for func_odbc that I'm currently trying to read to answer this
> question.
> 
> Tilghman (or anyone else who has determined the answer to this query),
> 
> I have googled, searched wikis, and I'm currently perusing the source
> code, but the long and short of it is that I cannot seem to find any
> reference to variables set by func_odbc calls such as something that
> would indicate if a query worked so that I can (in the dialplan)
> handle errors on the fly. Another item I'm trying to determine is the
> LAST_INSERT_ID...
> 
> Thoughts/Comments? I hope very much that I haven't overlooked
> something, but then again I'm no longer a spring chicken either....

Well, it depends upon what type of query you're performing.  If it is
a query which inserts/updates, then ODBC_ROWS will contain an
integer specifying the number of rows affected.  -1 is reserved for
a statement which failed, since it is perfectly possible for an UPDATE
to succeed, yet affect 0 rows.  For SELECT queries, however, that is a
much more difficult question, since it depends upon the particular query.
Again, it is perfectly possible for a SELECT query to successfully run, yet
return 0 rows.  Or it might be that with your dataset, you should never get
0 rows returned.  These are questions that must be pondered by the
particular data administrator, not answers that I can provide as the author
of the tool.

As far as LAST_INSERT_ID, that is a MySQL-ism that is not supported,
since it is not portable across database types.

-- 
Tilghman



More information about the asterisk-users mailing list