Re: [Zope] How can run multiple query in an Z sql method

2007-03-09 Thread Andreas Jung



--On 9. März 2007 14:42:57 +0530 Remil Mathew [EMAIL PROTECTED] wrote:


Hi,
How can run  multiple query in an Z sql method..


Sure. SQL Statement just have to separated by dtml-sql-delimiter.

I am using Mysql..

Also is there any method to return a value from insert query?


An insert statement does not return a value! If you are working
with sequences for generating the primary  key you might perform
a select on the current value of the related sequence.

-aj

pgpCeOnEf4T8A.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Tino Wildenhain

Andreas Jung schrieb:



--On 9. März 2007 14:42:57 +0530 Remil Mathew [EMAIL PROTECTED] wrote:


Hi,
How can run  multiple query in an Z sql method..


Sure. SQL Statement just have to separated by dtml-sql-delimiter.

I am using Mysql..

Also is there any method to return a value from insert query?


An insert statement does not return a value! If you are working
with sequences for generating the primary  key you might perform
a select on the current value of the related sequence.


Well, it can. See RETURNING clause:
http://www.postgresql.org/docs/8.2/static/sql-insert.html

but I doubt mysql supports this ... checking ... no, it doesnt.

Regards
Tino
___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Gaute Amundsen
On Friday 09 March 2007 10:12, Remil Mathew wrote:
 Hi,
 How can run  multiple query in an Z sql method.. I am using Mysql..
 Also is there any method to return a value from insert query?

 Thanks
 Remil

could you possibly be thinking of?

insert foo into bar
dtml-var sql_delimiter
SELECT LAST_INSERT_ID()


gaute
___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Jary Busato




Yes, I must do it when I need to know an autonumber PK after an insert.
when DB support transaction i write:

begin transaction
insert foo into bar
dtml-var sql_delimiter
SELECT LAST_INSERT_ID() as lastid
commit

Then, a DTML method:

dtml-in myZSQLinsertandselect()
dtml-var lastid
/dtml-in

Make the insert and write the id returned by the select.

Illorca

Gaute Amundsen ha scritto:

  On Friday 09 March 2007 10:12, Remil Mathew wrote:
  
  
Hi,
How can run  multiple query in an Z sql method.. I am using Mysql..
Also is there any method to return a value from insert query?

Thanks
Remil

  
  
could you possibly be thinking of?

insert foo into bar
dtml-var sql_delimiter
SELECT LAST_INSERT_ID()


gaute
___
Zope maillist  -  Zope@zope.org
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  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Andreas Jung



--On 9. März 2007 15:30:23 +0100 Jary Busato [EMAIL PROTECTED] wrote:


Yes, I must do it when I need to know an autonumber PK after an insert.
when DB support transaction i write:

begin transaction

insert foo into bar
dtml-var sql_delimiter
SELECT LAST_INSERT_ID() as lastid
commit


Sorry, but you must be crazy to perform you own transaction handling within 
Zope. Dealing with transactions is the task of Zope and your database but 
it is *not recommended* to perform your own transaction hand here...at least
not in this way. If you want o integration a third-party system the 
transaction handling of Zope: look at the DataManager API of Zope's

transaction module.

-aj



pgpCOvEGVPQep.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Jary Busato
My only need is to be sure to keep the right id; I did'nt use this 
method for other operations.
You sayd that it's not recommended but I don't understand why in this 
simple context.


Andreas Jung ha scritto:



--On 9. März 2007 15:30:23 +0100 Jary Busato [EMAIL PROTECTED] wrote:


Yes, I must do it when I need to know an autonumber PK after an insert.
when DB support transaction i write:

begin transaction

insert foo into bar
dtml-var sql_delimiter
SELECT LAST_INSERT_ID() as lastid
commit


Sorry, but you must be crazy to perform you own transaction handling 
within Zope. Dealing with transactions is the task of Zope and your 
database but it is *not recommended* to perform your own transaction 
hand here...at least
not in this way. If you want o integration a third-party system the 
transaction handling of Zope: look at the DataManager API of Zope's

transaction module.

-aj



___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Andreas Jung



--On 9. März 2007 16:45:56 +0100 Jary Busato [EMAIL PROTECTED] wrote:


My only need is to be sure to keep the right id; I did'nt use this method
for other operations.
You sayd that it's not recommended but I don't understand why in this
simple context.



Simple or complex context..that does not matter. It is just bad-style.

-aj

pgpD8jUybMYcl.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Marco Bizzarri

On 3/9/07, Jary Busato [EMAIL PROTECTED] wrote:

If I understood you're telling me that begin and commit statements are
redundant.


Yes, exactly: they are issued by Zope at the boundaries of a transaction.


Sometimes conflicts are not correctly managed by ZTM (no rollbacks in db)


Are you using a non-transactional database (like old MySQL version)?


--
Marco Bizzarri
http://iliveinpisa.blogspot.com/
___
Zope maillist  -  Zope@zope.org
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] How can run multiple query in an Z sql method

2007-03-09 Thread Marco Bizzarri

On 3/9/07, Jary Busato [EMAIL PROTECTED] wrote:

Marco Bizzarri ha scritto:
 On 3/9/07, Jary Busato [EMAIL PROTECTED] wrote:
 If I understood you're telling me that begin and commit statements are
 redundant.

 Yes, exactly: they are issued by Zope at the boundaries of a transaction.

 Sometimes conflicts are not correctly managed by ZTM (no rollbacks in
 db)

 Are you using a non-transactional database (like old MySQL version)?


sql server with ZODBC



Sorry, I don't have direct experience with it. However, IIRC, ZODBC is
quite old and could have some problems. I would suggest you to invest
a few Euros in mxODBC: I've never tried it but Egenix has a good
record of producing good products.

Regards
Marco


--
Marco Bizzarri
http://iliveinpisa.blogspot.com/
___
Zope maillist  -  Zope@zope.org
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 )