Re: perl and postgresql - Mailing list pgsql-novice

From Ville Jungman
Subject Re: perl and postgresql
Date
Msg-id F1240CaQv2u6Heluki400007dec@hotmail.com
Whole thread Raw
In response to perl and postgresql  ("Sugrue, Sean" <sean.sugrue@analog.com>)
List pgsql-novice
> > is much simpler than same query with placeholders. That's why I like to
>do
> > it with sub like this.
>
>It's not really that much easier

"But I'm used to this and it would be pain if I had to move back", yelled
Tim Toady, calmed down and continued: "Look at this call ripped from my
embperl-file:

$subs->kanta("
   select k.varaus_alkaa from kaavakkeet_tiedot t,kaavakkeet k
   where t.ref_kaavakkeet=k.id and k.varaus_alkaa <= $loppuaika
      and k.varaus_alkaa >= $alkuaika and t.ref_tuotteet=$ref_tuotteet

   union

   select k.varaus_paattyy from kaavakkeet_tiedot t,kaavakkeet k
   where t.ref_kaavakkeet=k.id and k.varaus_paattyy <= $loppuaika
      and k.varaus_paattyy >= $alkuaika and t.ref_tuotteet=$ref_tuotteet
");

You can't say that this would be clear to debug with placeholders. At least
if You'll someday study some Finnish the query above will look very clear -
so thinking failures are rare (or could be if some other than me was
programming). Queries are also much faster to write if they are many (like
with my current projects).

You (and [the other replyer called perhaps] Antti) are right in many things
about migrating, de facto standards etc. I'll keep them in mind. Also I
might have to convert the queries to use placeholders later - but only if
it'll make the sub faster. Perhaps i'll learn if something bad happens
because of my non-standard behaviours. Finally, I think that my sub was a
little bit insane == it just made what is asked.

Thank You for Your suggestions and advices."

---
Ville Jungman
Finland

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


pgsql-novice by date:

Previous
From: Keith Keller
Date:
Subject: Re: perl and postgresql
Next
From: John Gunther
Date:
Subject: Problems using palloc in postgresql user C functions