pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPOSTGRESQL and PERL?
4+ messages / 4 participants
[nested] [flat]
* POSTGRESQL and PERL?
@ 2000-05-26 15:58 Peter Landis <ntwebdeveloper@yahoo.com>
2000-05-26 16:35 ` Re: POSTGRESQL and PERL? Ed Loehr <eloehr@austin.rr.com>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Landis @ 2000-05-26 15:58 UTC (permalink / raw)
To: pgsql-sql; +Cc: pgsql-sql
Hi-
I'm a newbie at postgresql and was working on
sorting by category. What my question is, how do you
sort by category when using a variable. For instance,
you can sort by name in perl by doing:
$sqh = $dbh->prepare(q{select name from company order
by name;});
$sqh->execute();
but what if you have a variable set like:
$sort_selection = "name";
How do you sort by the variable?
For instance you cannot do:
$sqh = $dbh->prepare(q{select name from company order
by ?;});
$sqh->execute($sort_selection);
OR
$sqh = $dbh->prepare(q{select name from company order
by $sort_selection;});
$sqh->execute();
If anyone could help, I would greatly appreciate it.
Thanks again!
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: POSTGRESQL and PERL?
2000-05-26 15:58 POSTGRESQL and PERL? Peter Landis <ntwebdeveloper@yahoo.com>
@ 2000-05-26 16:35 ` Ed Loehr <eloehr@austin.rr.com>
2000-05-26 17:41 ` Re: POSTGRESQL and PERL? Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 4+ messages in thread
From: Ed Loehr @ 2000-05-26 16:35 UTC (permalink / raw)
To: Peter Landis <ntwebdeveloper@yahoo.com>; +Cc: pgsql-sql
Peter Landis wrote:
>
> but what if you have a variable set like:
> $sort_selection = "name";
>
> How do you sort by the variable?
>
> For instance you cannot do...
> $sqh = $dbh->prepare(q{select name from company order
> by $sort_selection;});
Why not? The query string is created before prepare is called...
Regards,
Ed Loehr
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: POSTGRESQL and PERL?
2000-05-26 15:58 POSTGRESQL and PERL? Peter Landis <ntwebdeveloper@yahoo.com>
2000-05-26 16:35 ` Re: POSTGRESQL and PERL? Ed Loehr <eloehr@austin.rr.com>
@ 2000-05-26 17:41 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 4+ messages in thread
From: Richard Huxton @ 2000-05-26 17:41 UTC (permalink / raw)
To: pgsql-sql
----- Original Message -----
From: Ed Loehr <eloehr@austin.rr.com>
To: Peter Landis <ntwebdeveloper@yahoo.com>
Cc: <pgsql-sql@postgresql.org>
Sent: Friday, May 26, 2000 5:35 PM
Subject: Re: [SQL] POSTGRESQL and PERL?
> Peter Landis wrote:
> >
> > but what if you have a variable set like:
> > $sort_selection = "name";
> >
> > How do you sort by the variable?
> >
> > For instance you cannot do...
> > $sqh = $dbh->prepare(q{select name from company order
> > by $sort_selection;});
>
> Why not? The query string is created before prepare is called...
>
I think you need qq{select ...} to indicate double-quoting "" or the
variable won't be substituted.
- Richard Huxton
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: POSTGRESQL and PERL?
@ 2000-05-26 16:14 Wallingford, Ted <twallingford@indexc.com>
0 siblings, 0 replies; 4+ messages in thread
From: Wallingford, Ted @ 2000-05-26 16:14 UTC (permalink / raw)
To: 'Peter Landis' <ntwebdeveloper@yahoo.com>; pgsql-sql; +Cc: pgsql-sql
Peter my guess is you can just substitute the variable name in for the
actual sortfield name..
select * from company order by $field;
That's why variables BEGIN with denotation characters in Perl rather than
ending with them (like in basic)..
Anyway, let me know if that works... and which module are you using to hit
PostgreSQL????
thax,
Ted
_________________________________________________
Ted Wallingford
Manager of Information Technology
Independence Excavating, Inc.
Precision Environmental Co.
Independence Communications, Inc.
www.indexc.com
> -----Original Message-----
> From: Peter Landis [mailto:ntwebdeveloper@yahoo.com]
> Sent: Friday, May 26, 2000 11:58 AM
> To: pgsql-sql@postgresql.org
> Cc: pgsql-sql@postgresql.org
> Subject: [SQL] POSTGRESQL and PERL?
>
>
>
> Hi-
> I'm a newbie at postgresql and was working on
> sorting by category. What my question is, how do you
> sort by category when using a variable. For instance,
> you can sort by name in perl by doing:
>
> $sqh = $dbh->prepare(q{select name from company order
> by name;});
> $sqh->execute();
>
> but what if you have a variable set like:
> $sort_selection = "name";
>
> How do you sort by the variable?
>
> For instance you cannot do:
> $sqh = $dbh->prepare(q{select name from company order
> by ?;});
> $sqh->execute($sort_selection);
>
> OR
>
> $sqh = $dbh->prepare(q{select name from company order
> by $sort_selection;});
> $sqh->execute();
>
> If anyone could help, I would greatly appreciate it.
>
> Thanks again!
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Kick off your party with Yahoo! Invites.
> http://invites.yahoo.com/
>
Attachments:
Wallingford, Ted.vcf (application/octet-stream, 136B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-05-26 17:41 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-05-26 15:58 POSTGRESQL and PERL? Peter Landis <ntwebdeveloper@yahoo.com>
2000-05-26 16:35 ` Ed Loehr <eloehr@austin.rr.com>
2000-05-26 17:41 ` Richard Huxton <dev@archonet.com>
2000-05-26 16:14 RE: POSTGRESQL and PERL? Wallingford, Ted <twallingford@indexc.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox