Anatomy of A Stored Procedure: Function Arguments
Anatomy of A Stored Procedure: Function Arguments
Similar to the way that Perl and the UNIX/Linux shells work, dollar quoting allows us to
choose a string to use in place of an opening and closing quote. By choosing a suitable string
that does not occur in our procedure, we do not need to use any escapes. A dollar quote is a
string of zero or more characters between $ characters. So, the previous example looks like this:
create function ... as $$ ... return 'string with a single '' in it '; ... $$ ...
If we have the string $$ in our procedure, we can choose a different dollar quote:
create function ... as $WHAT$ ... return 'string with a $$ in it '; ... $WHAT$ ...
The examples in this chapter from now on will use dollar quoting. If you are using a version of
PostgreSQL before 8.0, we suggest that you upgrade to the latest version. Otherwise, you will
need to use traditional quoting.
Thankfully, in PostgreSQL version 8.0 and later, the feature called dollar quoting is available.
Similar to the way that Perl and the UNIX/Linux shells work, dollar quoting allows us to
choose a string to use in place of an opening and closing quote. By choosing a suitable string
that does not occur in our procedure, we do not need to use any escapes. A dollar quote is a
string of zero or more characters between $ characters. So, the previous example looks like this:
create function ... as $$ ... return 'string with a single '' in it '; ... $$ ...
If we have the string $$ in our procedure, we can choose a different dollar quote:
create function ... as $WHAT$ ... return 'string with a $$ in it '; ... $WHAT$ ...
The examples in this chapter from now on will use dollar quoting. If you are using a version of
PostgreSQL before 8.0, we suggest that you upgrade to the latest version. Otherwise, you will
need to use traditional quoting.
Thankfully, in PostgreSQL version 8.0 and later, the feature called dollar quoting is available.
Similar to the way that Perl and the UNIX/Linux shells work, dollar quoting allows us to
choose a string to use in place of an opening and closing quote. By choosing a suitable string
that does not occur in our procedure, we do not need to use any escapes. A dollar quote is a
string of zero or more characters between $ characters. So, the previous example looks like this:
create function ... as $$ ... return 'string with a single '' in it '; ... $$ ...
If we have the string $$ in our procedure, we can choose a different dollar quote:
create function ... as $WHAT$ ... return 'string with a $$ in it '; ... $WHAT$ ...
The examples in this chapter from now on will use dollar quoting. If you are using a version of
PostgreSQL before 8.0, we suggest that you upgrade to the latest version. Otherwise, you will
need to use traditional quoting.