- publishing free software manuals
PostgreSQL Reference Manual - Volume 2 - Programming Guide
by The PostgreSQL Global Development Group
Paperback (6"x9"), 408 pages
ISBN 0954612035
RRP £19.95 ($34.95)

Sales of this book support the PostgreSQL project! Get a printed copy>>>

3.12.3 ifdef, ifndef, else, elif and endif directives

You can use the following directives to compile code sections conditionally:

EXEC SQL ifdef name;
Checks a name and processes subsequent lines if name has been created with EXEC SQL define name.
EXEC SQL ifndef name;
Checks a name and processes subsequent lines if name has not been created with EXEC SQL define name.
EXEC SQL else;
Starts processing an alternative section to a section introduced by either EXEC SQL ifdef name or EXEC SQL ifndef name.
EXEC SQL elif name;
Checks name and starts an alternative section if name has been created with EXEC SQL define name.
EXEC SQL endif;
Ends an alternative section.

Example:

exec sql ifndef TZVAR;
exec sql SET TIMEZONE TO 'GMT';
exec sql elif TZNAME;
exec sql SET TIMEZONE TO TZNAME;
exec sql else;
exec sql SET TIMEZONE TO TZVAR;
exec sql endif;
ISBN 0954612035PostgreSQL Reference Manual - Volume 2 - Programming GuideSee the print edition