Thread Multidimensionales Array mit Daten aus Datenbank füllen. (13 answers)
Opened by lordsirkendorf at 2009-09-16 14:55

Gast wer
 2009-09-16 15:05
#125863 #125863
versuch es mal so:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl -w

use strict;
use DBI;
use Data::Dumper;

my $dbname = 'xxx'
my $user = 'xxxxxx'
my $passwd = 'xxxx'

my $dbh = DBI->connect('DBI:Oracle:$dbname', '$user', '$passwd')
                or die "Couldn't connect to database: " . DBI->errstr;

my $sth = $dbh->prepare("select TABLESPACE_NAME, FILE_NAME, BYTES, MAXBYTES from dba_data_files where FILE_NAME like '%sapdata%' order by TABLESPACE_NAME")
                or die "Couldn't prepare statement: " . $dbh->errstr;

my @data;

$sth->execute
                or die "Couldn't execute statement: " . $sth->errstr;

while (my @line = $sth->fetchrow_array) {
  push(@data,\@line);
}
#
# alternativ:
#while (my $lineref = $sth->fetchrow_arrayref) {
#  push(@data,$lineref);
#}
#
# oder:
# @data=$sth->fetchall_array();

$sth->finish;

$dbh->disconnect;

print Dumper(\@data);

View full thread Multidimensionales Array mit Daten aus Datenbank füllen.