Re: Using q() to define a query
- From: Jenda@xxxxxxxxxxx (Jenda Krynicky)
- Date: Mon, 14 Jan 2008 20:52:23 +0100
From: "Peter J. Holzer" <hjp@xxxxxxxxx>
On 2008-01-14 13:07:17 +0100, Jenda Krynicky wrote:
From: "Peter J. Holzer" <hjp@xxxxxxxxx>
As an aside, the SPL programming language[2] allows the terminator of a
here document to be indented and to strip off everything up to and
including some character from each line, so that could be written like
this:
function foo() {
some;
code;
here;
if (bla) {
more;
code;
here;
var sql = >>SQL|
|SELECT
| jo.departure_date AS departure
|, eq.name AS equipment
|, dp.full_city AS departure_city
|, ap.full_city AS arrival_city
|, ca.name AS carrier_name
|, jo.number
|[...]
SQL;
even;
more;
}
code;
here;
}
That kinda defeats the purpose of heredocs, namely allowing me to
copy&paste some data into/out of the script without having to escape
or modify anything.
In most cases this works with q{} just the same (the only exception is
the sequence \\, which unfortunately represents only a single backslash
inside q{}.
And with the exception of an unballanced { or } which causes the
literal to end either too soon or too late.
Unlikely to occure in SQL I admit, not so in other things. Besides
the only difference as far as formatting goes is the end marker. With
heredoc it has to be at the beginning of a line, in case of q{} it
may be anywhere. If the leading whitespace is meaningfull in whatever
it is you are quoting, you have exactly the same problem with here-
docs and q{}.
Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
.
- References:
- Re: Using q() to define a query
- From: Peter J. Holzer
- Re: Using q() to define a query
- From: Jenda Krynicky
- Re: Using q() to define a query
- From: Peter J. Holzer
- Re: Using q() to define a query
- Prev by Date: RE: Using q() to define a query
- Next by Date: All tests fail for any other than user 'oracle'
- Previous by thread: Re: Using q() to define a query
- Next by thread: Which versions to use
- Index(es):