Author: paul
Date: 2006-09-28 15:53:55 +0200 (Thu, 28 Sep 2006)
New Revision: 3491
Log:
r8702@frost: paul | 2006-09-28 08:52:02 -0500
Move initial LAST_INSERT_ID() example to earlier in the section.
Add text describing the effect of stored routines/triggers
on LAST_INSERT_ID().
Modified:
trunk/refman-4.1/functions.xml
trunk/refman-5.0/functions.xml
trunk/refman-5.1/functions.xml
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:14099
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:8680
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:10466
+ 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:14099
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:8702
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:10466
Modified: trunk/refman-4.1/functions.xml
===================================================================
--- trunk/refman-4.1/functions.xml 2006-09-28 13:47:27 UTC (rev 3490)
+++ trunk/refman-4.1/functions.xml 2006-09-28 13:53:55 UTC (rev 3491)
Changed blocks: 2, Lines Added: 14, Lines Deleted: 10; 1705 bytes
@@ -13219,9 +13219,20 @@
<literal>AUTO_INCREMENT</literal> column by the
<emphasis>most recently executed</emphasis>
<literal>INSERT</literal> or <literal>UPDATE</literal>
- statement to affect such a column. The currently executing
- statement does not affect the value of
- <literal>LAST_INSERT_ID()</literal>. Suppose that you
+ statement to affect such a column. For example, after
+ inserting a row that generates an
+ <literal>AUTO_INCREMENT</literal> value, you can get the
+ value like this:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT LAST_INSERT_ID();</userinput>
+ -> 195
+</programlisting>
+
+ <para>
+ The currently executing statement does not affect the value
+ of <literal>LAST_INSERT_ID()</literal>. Suppose that you
generate an <literal>AUTO_INCREMENT</literal> value with one
statement, and then refer to
<literal>LAST_INSERT_ID()</literal> in a multiple-row
@@ -13238,13 +13249,6 @@
<remark role="help-description-end"/>
- <remark role="help-example"/>
-
-<programlisting>
-mysql> <userinput>SELECT LAST_INSERT_ID();</userinput>
- -> 195
-</programlisting>
-
<para>
The ID that was generated is maintained in the server on a
<emphasis>per-connection basis</emphasis>. This means that
Modified: trunk/refman-5.0/functions.xml
===================================================================
--- trunk/refman-5.0/functions.xml 2006-09-28 13:47:27 UTC (rev 3490)
+++ trunk/refman-5.0/functions.xml 2006-09-28 13:53:55 UTC (rev 3491)
Changed blocks: 2, Lines Added: 44, Lines Deleted: 9; 3004 bytes
@@ -13311,9 +13311,20 @@
<literal>AUTO_INCREMENT</literal> column by the
<emphasis>most recently executed</emphasis>
<literal>INSERT</literal> or <literal>UPDATE</literal>
- statement to affect such a column. The currently executing
- statement does not affect the value of
- <literal>LAST_INSERT_ID()</literal>. Suppose that you
+ statement to affect such a column. For example, after
+ inserting a row that generates an
+ <literal>AUTO_INCREMENT</literal> value, you can get the
+ value like this:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT LAST_INSERT_ID();</userinput>
+ -> 195
+</programlisting>
+
+ <para>
+ The currently executing statement does not affect the value
+ of <literal>LAST_INSERT_ID()</literal>. Suppose that you
generate an <literal>AUTO_INCREMENT</literal> value with one
statement, and then refer to
<literal>LAST_INSERT_ID()</literal> in a multiple-row
@@ -13328,15 +13339,39 @@
the effect is undefined.)
</para>
- <remark role="help-description-end"/>
+ <para>
+ Within the body of a stored routine (procedure or function)
+ or a trigger, the value of
+ <literal>LAST_INSERT_ID()</literal> changes the same way as
+ for statements executed outside the body of these kinds of
+ objects. The effect of a stored routine or trigger upon the
+ value of <literal>LAST_INSERT_ID()</literal> that is seen by
+ following statements depends on the kind of routine:
+ </para>
- <remark role="help-example"/>
+ <itemizedlist>
-<programlisting>
-mysql> <userinput>SELECT LAST_INSERT_ID();</userinput>
- -> 195
-</programlisting>
+ <listitem>
+ <para>
+ If a stored procedure executes statements that change
+ the value of <literal>LAST_INSERT_ID()</literal>, the
+ changed value will be seen by statements that follow the
+ procedure call.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ For stored functions and triggers that change the value,
+ the value is restored when the function or trigger ends,
+ so following statements will not see a changed value.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <remark role="help-description-end"/>
+
<para>
The ID that was generated is maintained in the server on a
<emphasis>per-connection basis</emphasis>. This means that
Modified: trunk/refman-5.1/functions.xml
===================================================================
--- trunk/refman-5.1/functions.xml 2006-09-28 13:47:27 UTC (rev 3490)
+++ trunk/refman-5.1/functions.xml 2006-09-28 13:53:55 UTC (rev 3491)
Changed blocks: 2, Lines Added: 44, Lines Deleted: 9; 3004 bytes
@@ -13848,9 +13848,20 @@
<literal>AUTO_INCREMENT</literal> column by the
<emphasis>most recently executed</emphasis>
<literal>INSERT</literal> or <literal>UPDATE</literal>
- statement to affect such a column. The currently executing
- statement does not affect the value of
- <literal>LAST_INSERT_ID()</literal>. Suppose that you
+ statement to affect such a column. For example, after
+ inserting a row that generates an
+ <literal>AUTO_INCREMENT</literal> value, you can get the
+ value like this:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT LAST_INSERT_ID();</userinput>
+ -> 195
+</programlisting>
+
+ <para>
+ The currently executing statement does not affect the value
+ of <literal>LAST_INSERT_ID()</literal>. Suppose that you
generate an <literal>AUTO_INCREMENT</literal> value with one
statement, and then refer to
<literal>LAST_INSERT_ID()</literal> in a multiple-row
@@ -13865,15 +13876,39 @@
the effect is undefined.)
</para>
- <remark role="help-description-end"/>
+ <para>
+ Within the body of a stored routine (procedure or function)
+ or a trigger, the value of
+ <literal>LAST_INSERT_ID()</literal> changes the same way as
+ for statements executed outside the body of these kinds of
+ objects. The effect of a stored routine or trigger upon the
+ value of <literal>LAST_INSERT_ID()</literal> that is seen by
+ following statements depends on the kind of routine:
+ </para>
- <remark role="help-example"/>
+ <itemizedlist>
-<programlisting>
-mysql> <userinput>SELECT LAST_INSERT_ID();</userinput>
- -> 195
-</programlisting>
+ <listitem>
+ <para>
+ If a stored procedure executes statements that change
+ the value of <literal>LAST_INSERT_ID()</literal>, the
+ changed value will be seen by statements that follow the
+ procedure call.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ For stored functions and triggers that change the value,
+ the value is restored when the function or trigger ends,
+ so following statements will not see a changed value.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <remark role="help-description-end"/>
+
<para>
The ID that was generated is maintained in the server on a
<emphasis>per-connection basis</emphasis>. This means that
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r3491 - in trunk: . refman-4.1 refman-5.0 refman-5.1 | paul | 28 Sep |