[Zope] Problen wtih dtml-in inside Zsql method
Dieter Maurer
dieter@handshake.de
Wed, 8 Nov 2000 22:19:02 +0100 (CET)
Alejandro Pancani writes:
> .... The problem is that when I execute the Zsql
> method 'sql_2' it seems to execute the sql_select_next_val method two times
> because at the next time that I execute 'sql_2' the value returned from
> sql_select_next_val is incremented in 2 in comparison with last value
> returned. I need it to be incremented in 1.
>
>
>
> the code of sql_select_nextval method is the following:
>
> SELECT seq.NEXTVAL val
> FROM DUAL
>
>
> the code of sql_2 method is the following:
>
> <dtml-in "sql_select_nextval">
>
> insert into anytable
> (oid_anytable, name)
> values
> (<dtml-var val>,
> 'john')
>
> <dtml-var sql_delimiter>
>
> select * from anytable where oid_anytable = <dtml-var val>
>
> </dtml-in>
Try to remove the "..." around "sql_select_nextval".
I do not understand why your code with the "..." works at all.
If this does not solve your problem, you may try:
insert into anytable (oid_anytable, name)
values (seq.NEXTVAL,'john')
<dtml-var sql_delimiter>
select * from anytable where oid_anytable = seq.CURVAL
That's the code, we use successfully ('CURVAL' may be wrongly spelled,
though).
Dieter