This might be a little more fun to respond to than I thought because the
characters look different when I past them into the e-mail. I'll try to type
over them and make them look right."
$state->execute || die "can't execute\n$sth->errstr\n";
print join(', ', @{$state->{NAME}});
$state->bind_columns(undef, \(@val{@{$state->{NAME}}}));
while ($row = $sth->fetchrow_arrayref) {
print $val{USER_ID} . "\n";
}
What I am doing there is dereferencing a reference returned by the NAME call
in the statement handle ($state in this case) Dereferencing it returns a
list of column names as I put in the print join statement. You can carry
this out as I did in the bind_columns function and use this function to bind
the columns so that you can refer to them by the original name. This should
work faster than the way a fetchrow_hashref works.
In your case when you do this, you can get the value of your columns in
$val{USER_ID}, $val{PASSWORD}, $val{KOKYAKU_CD} etc.
Does this give you what you need?
Steve H.
-----Original Message-----
From: Karina Nahagama [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 11, 2001 11:51 PM
To: [EMAIL PROTECTED]
Subject: About DBI and Oracle
My name is Karina Nagahama.
I want to know about DBI.
I'm working on Windows NT, Apache, Perl, mod_perl Oracle8 and DBI.
I'm using DBI in a .pm file.
In order to select information from the database I wrote wrote the next
sentences:
my $state = $dbhandler->prepare(q{SELECT USER_ID, PASSWORD, KOKYAKU_CD,
KYOTEN_CD FROM T_M_WEB_USER});
$state->execute();
Then in order to read the information selected, I wrote the next sentences:
while (my $record = $state->fetchrow_arrayref){
print '<BR> User ID : ', $record->[0]; #[USER_ID]
print ' PASSWORD : ', $record->[1]; #[PASSWORD]
}
In this case I have to pick-up the field information with the field number
$record->[0].
I want to pick-up the selected information by calling the fields by their
names.
How can I pick-up the field information with the field name ? (for example
USER_ID)
Sorry for trouble you.
[EMAIL PROTECTED]