Re[2]: [Zope] Returning incremented id from mysql query?

Dmitry Matveev Dmitry Matveev <matveev@uralfirm.ru>
Thu, 15 Aug 2002 12:47:55 +0600


 You can use like this in sql(suppose it named sql_subscriptions_insert):

insert into subscriptions(
user_id, ...
)
values (
<dtml-sqlvar user_id type=int>, 
...
)
</dtml-if>
<dtml-var sql_delimiter>  
select currval('subs_subscription_id_seq') as subscription_id

and in  python script:

subscription_id = context.sql_subscriptions_insert(request)[0]['subscription_id']

 
EL> On Wednesday, August 14, 2002, at 07:21  PM, Alec Munro wrote:

>> I'm looking for a way to get the id generated when I insert data into a
>> table with an auto-incremented key?
>> I've found vague references to this, but assuming I do an insert from a
>> python script, calling an SQL method like:
>> container.SQL.insertSomething(name="bob")
>> how would I get the id.
>>
>> Thanks very much, hope someone can help me with this.


-- 
Best regards,                          www.uralfirm.ru
Dmitry Matveev                         mailto:matveev@uralfirm.ru