- publishing free software manuals
The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming Guide
by The PostgreSQL Global Development Group
Paperback (6"x9"), 478 pages
ISBN 9781906966065
RRP £14.95 ($19.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 9781906966065The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming GuideSee the print edition