[ic] Column-names part II

Rene Hertell interchange-users@icdevgroup.org
Sun Aug 18 08:55:19 2002


> > > This is basic programming -- you always use arrays. We could build our
> > > own array with pointers, but you can even get help from DBI
> and IC with
> > > a hash query type...
> > >
> > > [perl]
> > > 	my $db = $Db{query};
> > > 	my $q = 'select * from address';
> > > 	my $ary = $db->query( { sql => $q, hashref => 1 });
> > > 	defined $ary
> > > 		or die errmsg("query error for %s!", $q);
> > >
> > > 	my @out;
> > > 	foreach my $row (@$ary) {
> > > 	    push @out, "Address for $row->{code} is $row->{address}";
> > > 	}
> > > 	return join "<br>", @out;
> > > [/perl]
> >
> > Sorry to bother you again, but I get an error in the catalogs
> error.log:
> > Safe: Can't call method "query" on an undefined value at (eval
> 181) line 4
> >
> > I tried to add query to SafeUntrap, but then I couldn't get IC
> to start...
> >
>
> I think you need to read some.
>
> I made a typo, i.e. $Db{query} instead of $Db{address}. You should
> have picked that up.

Mike!

I wan't to thank you for this code-example! Now I learned a lot from arrays,
how to handle them and how to pull out data from the db with perl! :-)

Regards,

Rene