[ic] trying to get a handle on this user tag thing

Kevin Walsh interchange-users@icdevgroup.org
Wed Oct 2 15:44:01 2002


C.B. Currier [cbcurrier@spinrx.com] wrote:
> 
> I am trying to get the syntax to get a db handle for querying the current
> db. Below is a sample of the code I have been using but have been getting
> the following error.  I have debugged the sql syntax and found it to work
> correctly, not returning a null or 0 record result set. But I believe that
> the result set returned is not compatable with my variable. Any guidance on
> this is much appreciated.
> 
> C.B.
> 
> Code:
> 
> 	sub {
> 		my $itmcount = 0;
> 
> 		my $tdb = $db{SKUShipZones};
> 
> 		my $cart = $Carts->{main};
> 		$itmcount = @$cart;
> 		foreach (@$cart){
> 			my $sql = 'Select * from SKUShipZones where sku = \''.$_->{code}.'\';';
> 			my $qry = $Tag->query({sql => $sql,});
> 			foreach (@$qry){
> #				<<<DO BLA >>>
> 			}
> 		}
> 		return bla;
> 	}
> 	EOF
> 
> Error:
> 
> Runtime error: Can't use string ("") as an ARRAY ref while "strict refs" in
> use at (eval 185) line 11
> 
Get an appropriate $db object with:

    my $db = ::database_exists_ref('tablename') or die 'Who ate my table?';

Then do your query like this:

    my $resultset = $db->query($sql};

Your strange-looking UPPERLowerCase table name may trip things up.
I seem to remember that it might, although I could be wrong.
That'd be easy to fix.

By the way, there's no need for a ';' at the end of your SQL statement.

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/