Thread Class::DBI (Probleme) (2 answers)
Opened by redpantyhose at 2008-09-01 14:00

redpantyhose
 2008-09-01 14:00
#114190 #114190
User since
2005-12-08
12 Artikel
BenutzerIn
[default_avatar]
Hallo zusammen !

Ich habe folgendes Problem mit Class::DBI:

Datenbank: PostgreSQL

Wenn ich folgendes versuche:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
# t_domains inventory
my @domains = cast2db::Class_t_domains->inventory('10.10.1.50');

my $obj;
foreach (@domains) {

        $obj = cast2db::Class_t_domains->retrieve($_);
        print $obj->domain;

}


Erhalte ich immer folgende Fehlermeldung:

"Can't retrieve a reference at ./cast2.pl line 32"

Ich weiss nicht mehr weiter ;.(

Wenn ich $_ durch eine Zahl ersetze die dem id-Wert in der DB entspricht :

Code (perl): (dl )
1
2
        $obj = cast2db::Class_t_domains->retrieve(4);
        print $obj->domain;


'4' ist der id der domain "wgbs.ch" in der Postgres Datenbank.

Erhalte ich folgendes:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
DBD::Pg::st execute failed: ERROR:  syntax error at or near "primary" at character 27
[for Statement "SELECT essential, domain, primary
FROM t_domains
WHERE id_t_domains=?
" with ParamValues: 1='4'] at /usr/lib/perl5/vendor_perl/5.8.8/DBIx/ContextualFetch.pm line 52.
DBD::Pg::st execute failed: ERROR: syntax error at or near "primary" at character 27
[for Statement "SELECT essential, domain, primary
FROM t_domains
WHERE id_t_domains=?
" with ParamValues: 1='4'] at /usr/lib/perl5/vendor_perl/5.8.8/DBIx/ContextualFetch.pm line 52.


Vielen Dank für Tipps ...


#########################################

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
39
40
41
42
43
44
45
46
47
48
49
package cast2db::Class_t_domains;

use strict;

# Class::DBI
use base qw(cast2db::Class_db_configure);

# table
cast2db::Class_t_domains->table('t_domains');

# tuples
cast2db::Class_t_domains->columns(
                All => qw/id_t_domains domain/,
                Primary => qw/id_t_domains/,
                Essential => qw/domain/,
                #Others => qw//,
);

sub inventory {
        my $self = shift;
        my $inet_addr = shift || $self;
        my $domain;
        my @domains;
        my $id_t_domains;
        my @id_t_domains;

        open (NSLOOKUP, "-|", "nslookup $inet_addr") or die;
        while(<NSLOOKUP>){
                if (/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.in-addr\.arpa\sname\s=\s\w+\.(.*)\.$/) {
                        push (@domains,$1);
                }
        }
        close(NSLOOKUP);

        # uniq
        @domains = keys %{{ map { $_ => 1 } @domains }};

        # ;.) Hardcore Perl
        @domains || push(@domains, 'unknown');

        # get @id_t_domains
        foreach $domain (@domains) {
                $id_t_domains = cast2db::Class_t_domains->find_or_create( domain => $domain );
                push(@id_t_domains,$id_t_domains);
        }

        # return id's
        return @id_t_domains;
}


# Data::Dumper Output

Code: (dl )
1
2
3
4
5
6
$VAR1 = bless( {
'__triggers' => {},
'_class_trigger_results' => [],
'id_t_domains' => '4'
}, 'cast2db::Class_t_domains' );
Can't retrieve a reference at ./cast2.pl line 34

View full thread Class::DBI (Probleme)