Re: [Zope] Getting Auto Increment value

2009-06-11 Thread Thomas Bennett
I am suspecting that serial in MySQL works like serial in PostgreSQL in which 
a sequence is automatically created.  If so, you should be able to query the 
last_value field in the sequence without having to call the function.  The 
field 
name might be different in MySQL, I don't know.  This will give you the last 
value inserted and if you need the next just add 1.

  Also, if it is an auto increment column and again if it is like PostgreSQL 
then all you have to do is use the word 'default' without quotes and it "auto 
increments" the value for the new insert.  See if there is a default for your 
serial field.

Thomas





On Thursday 11 June 2009 08:36:21 Merav Ben-David wrote:
> I am working with zope & mysql.
>
> I have a table with SERIAL column type, I create "z-sql method" for insert
> operation, how can I get the value for the auto increment column?
>
> I know that in mysql I can call last_insert_id(),  how do I call it, should
> I create another "z sql method" and if I do,  how can I be sure the the
> value return is for my insert command and not for another. Is there a way
> to call 2 query from the same "z sql method"?
>
>
>
> I am really lost on this, any help will be wellcom.
>
> Thank in advanced.

-- 
 Normally I'm against big things, 
 I think the world is going to be saved by millions of small things. 
Too many things can go wrong when they get big.
- Pete Seeger  at his 90th birthday party Sunday May 3, 2009

==
Thomas McMillan Grant Bennett   Appalachian State University
Operations & Systems AnalystP O Box 32026
University LibraryBoone, North Carolina 28608
(828) 262 6587

Library Systems Help Desk: https://www.library.appstate.edu/help/
==
___
Zope maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Getting Auto Increment value

2009-06-11 Thread robert rottermann
to my knowledge SELECT LAST_INSERT_ID();
is per connection.
so if you do the call in the same request in which you did the the creation of
the record, you should be fine
robert
Merav Ben-David schrieb:
> 
> 
>  
> 
> I am working with zope & mysql.
> 
> I have a table with SERIAL column type, I create "z-sql method" for
> insert operation, how can I get the value for the auto increment column?
> 
> I know that in mysql I can call last_insert_id(),  how do I call it,
> should I create another "z sql method" and if I do,  how can I be sure
> the the value return is for my insert command and not for another. Is
> there a way to call 2 query from the same "z sql method"?
> 
>  
> 
> I am really lost on this, any help will be wellcom.
> 
> Thank in advanced.
> 
> 
> 
> 
> ___
> Zope maillist  -  [email protected]
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )

___
Zope maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Getting Auto Increment value

2009-06-11 Thread Andreas Jung
On 11.06.09 14:36, Merav Ben-David wrote:
>
>  
>
> I am working with zope & mysql.
>
> I have a table with SERIAL column type, I create “z-sql method” for
> insert operation, how can I get the value for the auto increment column?
>
> I know that in mysql I can call last_insert_id(),  how do I call it,
> should I create another “z sql method” and if I do,  how can I be sure
> the the value return is for my insert command and not for another. Is
> there a way to call 2 query from the same “z sql method”?
>
>  
>
> I am really lost on this, any help will be wellcom.
>
> Thank in advanced.
>

You should be able to write two ZSQL methods and wrap them into a
PythonScript. So you call the PythonScript
instead of the ZSQL method(s) directly. In addition there is a
sql-delimiter tag in DTML afaik - possibly
undocumented. I would go for the PythonScript + 2 ZSQL methods approach.

-aj
begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[email protected]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard

___
Zope maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Getting Auto Increment value

2009-06-11 Thread Merav Ben-David
 

I am working with zope & mysql.

I have a table with SERIAL column type, I create "z-sql method" for insert 
operation, how can I get the value for the auto increment column?

I know that in mysql I can call last_insert_id(),  how do I call it, should I 
create another "z sql method" and if I do,  how can I be sure the the value 
return is for my insert command and not for another. Is there a way to call 2 
query from the same "z sql method"?

 

I am really lost on this, any help will be wellcom.

Thank in advanced.

___
Zope maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )