[EMAIL PROTECTED] wrote:
> I have another situation where I am calling a select
> subroutine in PERL based on the table a user selects.
> This select statement is very basic:
>
> select * from $tablename
>
> From here how do I pick only the columns of my choice?
Well, if you know which columns you want, you can say so:
select price, description, partnumber from $tablename
If you don't know in advance what columns there are, how will you choose
which ones you want?
However, if you use DBI and the classic prepare-execute-fetch-fetch-fetch
method, you can use the statement handle you get to obtain the column names:
$sth->{NAME} (or NAME_lc or NAME_uc) gives the an arrayref containing the
names of the columns (either in the driver's default case, or lowercase, or
uppercase, respectively).
>From this you might be able to decide which columns you want, and then take
only those. For example, if you determine you only want the first, fourth,
and fifth columns, you can use $row = $sth->fetch and then use
@{$row}[0,3,4].
Cheers,
Philip
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]