Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

[GENERAL] "and then" / "or else"

From: Christian Schröder <cs(at)deriva.de>
Date: Sat Nov 17 2007 - 03:53:40 EST


Hi list,
the logical operators "and" and "or" are commutative, i.e. there is no "short-circuiting". Especially when doing PL/pgSQL development it would sometimes be very handy to have this short circuiting. Unfortunately, the trick from the docs (chapter 4.2.12) using "case ... then" does not work inside an "if" statement (the "then" of the "case" is interpreted as belonging to the "if" and thus leads to a syntax error). Of course, I can sometimes use nested "if" statements, but that doesn't always meet the logical requirements and leads to less readable code. Some programming languages (e.g. Eiffel) know the operators "and then" and "or else" which explicitly are "short-circuited". Would it be possible to add these operators to PostgreSQL in general or at least to the PL/pgSQL syntax?

Regards,

    Christian

-- 
Deriva GmbH                         Tel.: +49 551 489500-42
Financial IT and Consulting         Fax:  +49 551 489500-91
Hans-Böckler-Straße 2                  
http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: 
http://www.deriva.de/deriva-ca.cer


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
Received on Sat Nov 17 03:55:35 2007

This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 20:06:29 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library