[asterisk-dev] func_odbc: Get the primary key for inserted row?

Johan Wilfer lists at jttech.se
Sun Jul 17 14:43:20 CDT 2011


I'm in the process of migrating some asterisk 1.4 systems to 1.6.2 and
after that to 1.8, and I must say I'm very impressed with func_odbc. It
worked well with 1.4 but now the multi-row queries for example making it
an even sharper tool.

One thing I havn't been able to do in a "clean" way however is to grab
the primary key of the row that has just been inserted. It's possible to
insert something unique and then select for it - that's the workaround I
use right now.

To take php as an example here there is the function mysql_insert_id (1)
(2) that returns this information. I did go through the files in
funcs/func_odbc.c and res/res_odbc.c in asterisk trunk to see if there
was a reference to get the primary key or the id but I couldn't find it.
Google told me there was something called "cursors" in ODBC related to
this, but maybe I got that wrong (3), no reference to this in the source
either.

Have I missed anything obvious? Is this hard to implement?

Ideas?

/Johan

(1) http://php.net/manual/en/function.mysql-insert-id.php
(2) http://dev.mysql.com/doc/refman/5.0/es/mysql-insert-id.html
(3)
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/r0000602.htm

-- 
Johan Wilfer                 email: johan at jttech.se
JT Tech | Utvecklare         webb: http://jttech.se
direkt: +46 31 380 91 01  support: +46 31 380 91 00




More information about the asterisk-dev mailing list