Skip to content
Snippets Groups Projects
Commit f28d9b10 authored by Tom Lane's avatar Tom Lane
Browse files

Document SQL functions' behavior of parsing the whole function at once.

Haribabu Kommi, somewhat rewritten by me
parent bfaa8c66
No related branches found
No related tags found
No related merge requests found
...@@ -143,6 +143,21 @@ SELECT clean_emp(); ...@@ -143,6 +143,21 @@ SELECT clean_emp();
</screen> </screen>
</para> </para>
<note>
<para>
The entire body of a SQL function is parsed before any of it is
executed. While a SQL function can contain commands that alter
the system catalogs (e.g., <command>CREATE TABLE</>), the effects
of such commands will not be visible during parse analysis of
later commands in the function. Thus, for example,
<literal>CREATE TABLE foo (...); INSERT INTO foo VALUES(...);</literal>
will not work as desired if packaged up into a single SQL function,
since <structname>foo</> won't exist yet when the <command>INSERT</>
command is parsed. It's recommended to use <application>PL/PgSQL</>
instead of a SQL function in this type of situation.
</para>
</note>
<para> <para>
The syntax of the <command>CREATE FUNCTION</command> command requires The syntax of the <command>CREATE FUNCTION</command> command requires
the function body to be written as a string constant. It is usually the function body to be written as a string constant. It is usually
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment