[ic] perl db question, problems when modifying admin

Mike Heins interchange-users@interchange.redhat.com
Mon Feb 18 15:35:01 2002


Quoting Doug Alcorn (lathi@seapine.com):
> 
> Mike Heins <mheins@redhat.com> writes:
> 
> > It should be wrapped and work on all later versions of IC, but I will
> > admit I haven't tried all functions. The reason is, all of this is a
> > heck of a lot easier with:
> > 
> > [perl products]
> > 	my $db = $Db{products};
> > 	my $phone = $Scratch->{item_code};
> > 	my $rowdata = $db->row_hash($phone);
> > 	my @cols = $db->columns();
> > 	&etc, &etc;
> > [/perl]
> 
> I this case of "select * from products where sku='$code'", yes it is
> easier.  However, some more complicated examples aren't.
> Specifically, when you have more complicated where clauses and actual
> joins.

That's pretty easy, too:

	my $q = 'select something from very_long_hairy_query';
 	my $rowary = $db->query({
					hashref => 1,
					query => $q,
			);

	for(@$rowary) {
		my $rowdata = $_;
		&etc;
	}

Again, the DBI object should be OK in later versions of IC. In 4.6.x you
will run into problems.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Friends don't let friends use Outlook. -- Bob Blaylock