Database Reference
In-Depth Information
Advantages of RAISE NOTICE
Using the RAISE NOTICE form of debugging has several advantages. It can be used
easily and repeatedly with scripts for regression testing. This is very easily accom-
plished with the command-line client. Consider the following statement:
psql -qtc "SELECT
format_us_full_name_debug('Mr','Kirk','L.','Roybal','Author');"
The preceding statement produces the following output to stdout :
NOTICE: firstname mi.: Kirk L..
NOTICE: firstname mi. lastname: Kirk L.. Roybal
NOTICE: prefix. firstname mi lastname: Mr.
Kirk L.. Roybal
NOTICE: prefix. firstname mi lastname,
suffix.: Mr. Kirk L.. Roybal, Author.
Mr. Kirk L.. Roybal, Author.
Because a constant set of input parameters should always produce a known output,
it is very easy to use command-line tools to test for expected outputs. When you
are ready to deploy your newly modified code to the production system, run your
command-line tests to verify that all of your functions still work as expected.
RAISE NOTICE is included with the product and requires no installation. This ad-
vantage will become clearer later in the chapter where the rather painful installation
procedure for PL/pgSQL Debugger is explained.
The RAISE statement is easy to understand. The syntax is very straightforward and
it is well documented at http://www.postgresql.org/docs/current/static/plpgsql-errors-
and-messages.html .
RAISE works in any development environment and has been around for a very long
time in almost every version of PostgreSQL on every operating system. I have used
it with pgAdmin3 , phpPgAdmin , as well as the command-line tool psql .
Search WWH ::




Custom Search