$$ is the delimiter you use to indicate where the function definition begins and ends. Consider the following:
CREATE TABLE <name> <definition goes here> <options go here, eg: WITH OIDS>
The syntax of the create function is similar, but since you are going to use all kinds of SQL in your function (especially the end of a statement, a character), the parser will be disabled if you do not separate it. Therefore, you should read your expression as:
CREATE OR REPLACE FUNCTION check_phone_number(text) RETURNS boolean AS <code delimited by $$> LANGUAGE plpgsql STRICT IMMUTABLE;
Material after the actual definition is an option to provide the database with additional information about your function, so it can optimize its use.
In fact, if you look in the section β4.1.2.2. Corrected Strings in Dollarsβ in the manual, you will see that you can even use the characters between the characters of the dollar, and all of them will be considered as one separator.
Captain Coder Aug 27 '12 at 15:21 2012-08-27 15:21
source share