Re: postgresql and perl? - Mailing list pgsql-general

From Herbert Liechti
Subject Re: postgresql and perl?
Date
Msg-id 392D9F62.7E9D8CA9@thinx.ch
Whole thread Raw
In response to postgresql and perl?  (Peter Landis <ntwebdeveloper@yahoo.com>)
List pgsql-general
Peter Landis wrote:
>
>
> How do you sort by the variable?
>
> $sqh = $dbh->prepare(q{select name from company order
> by $sort_selection;});
> $sqh->execute();

Your problem is not Perl specific. The order by column
must be in the result set (projection). Why not doing
it this way:

my @fields = qw/name zip location/;
push @fields, $sort_selection;

$sqh = $dbh->prepare( "SELECT " . join(', ', @fields) .
     " FROM company ORDER BY $sort_selction; );
$sqh->execute();

Greetings Herbie
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti                     E-Mail: Herbert.Liechti@thinx.ch
ThinX networked business services        Stahlrain 10, CH-5200 Brugg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pgsql-general by date:

Previous
From: Peter Landis
Date:
Subject: postgresql and perl?
Next
From: Tom Lane
Date:
Subject: Re: problem with NOTICE: _outNode: don't know how to print type