[ic] Query Tag - how do I get a single value?

Mark Gibson interchange-users@icdevgroup.org
Tue Nov 19 10:58:00 2002


Hi,
 	I forgot to mention originally, that I'm trying to do this in a
UserTag, not an embedded [perl] tag.
But the $Sql{..} always fails:

my $dbh = $Sql{products} or return 'Failed to get dbh';

Is $Sql{...} in the documentation somewhere?

On Tuesday 19 Nov 2002 3:20 pm, Mike Heins wrote:
> >
> > 	$Tag->query("SELECT custom_function('$body')");
> >
> > I would like to get back a single scalar value from this call,
>
> You should use either the standard access method:
> or the DBI you are used to:
>
> 	[perl tables=products]
> 		my $dbh = $Sql{products};
> 		my $sth = $dbh->prepare("SELECT custom_function('$body')")
> 			or die "Bad query prepare!";
> 		my ($result) = $sth->selectrow_array();
> 		return $result;
> 	[/perl]

-- 
Mark Gibson <gibsonm@cromwell-tools.co.uk>
Web Developer
Cromwell Group Holdings Ltd