[ic] Return auto_increment value from [query] INSERT

Paul Jordan interchange-users@icdevgroup.org
Tue May 6 21:30:01 2003


Hi guys      IC 4.9.7   MYSQL 3.2XXXXX

I have a [query] INSERT statement, and the table it is on has an
auto_increment primary key. A little birdie told me that it was possible to
do an INSERT and also be able to grab the auto_incremented value...

[query
    st=sql
    table="messages"
    type=list
    sql=|
        INSERT  messages
        SET     message_id = '',
                call_id = '[scratch callid]',
                direction = '2',
                message_source = 'SeeBase',
   [snip "code"]
                to_email = '',
                subject = '[value resub]',
                status = '4'
        |][seti new_id][sql-pos 0][/seti][/query]


What's the deal here... [sql-code], [sql-last-code], [sql-pos -1],
[you-know-what-I-mean-code].. Do I need to utilize a 'sequenced' table
instead of auto_increment to track this, in order to pull the value? I was
under the impression I wouldn't have to go that route. I have tried the
above many ways, with and without the initial message_id = '',

Any hints would be greatly appreciated.

Paul