maxdb wrote > > If i create a table that have a field of type serial(1) and insert a row > on it.... how to determine the currval for this field on this table when > insert new values on a store procedure? >
select mytable.currval from DUAL DUAL is THE table for doing this, because it has exactly one row and you do not have the problem of selecting x rows in your sometable or whatever else. CURRVAL will always return the last used value of the corresponding sequence/serial in THIS current session --> 1. no problem with multi-user-systems 2. if no NEXTVAL for the sequence resp. no INSERT for the table with the serial is done before asking for CURRVAL, an error will be returned. This can be used in stored procs or outside. If you want to use the value in an insert-trigger, using the column_name as value (as with all other column-values in triggers) would be convenient and get rid of this extra call. Or if the value is used only once, for example in an update into another table, UPDATE other_table SET col = mytable.currval WHERE ... Should do Elke SAP Labs Berlin > > -- > MaxDB Discussion Mailing List > For list archives: http://lists.mysql.com/maxdb > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]