[ic] Tag->query in a usertag

Ron Phipps interchange-users@interchange.redhat.com
Thu Apr 18 20:07:01 2002


I'm attempting to write a routine that will return a list of quantity
break fields that contain data.  I have the following code that works
correctly in a [perl] section, but will not function correctly in a
usertag.  The query tag is supposed to return a reference to an array of
hash references.  I have tested that this indeed works in a [perl]
section.

Here are the two pieces of code.

Inline:

		[perl tables=pricing]
			my $code = 'test-001';
			my $available_breaks =
"q2,q3,q4,q5,q6,q7,q8,q9,q10,q12,q15,q25,q50,q100";

			my $break;
			my $sql = "SELECT " . $available_breaks . " FROM
pricing WHERE sku ='" . $code . "';";	

			my $sql_results = $Tag->query( {sql => $sql,
hashref => 'price_results' } );

			my $out = ref($sql_results);
			return $out;
		[/perl]

Usertag (included in config.cfg using, include usertag/*)

UserTag get-valid-qty-break-fields Routine <<EOR
sub {
	my $code = 'test-001';
	my $available_breaks =
"q2,q3,q4,q5,q6,q7,q8,q9,q10,q12,q15,q25,q50,q100";

	my $break;
	my $sql = "SELECT " . $available_breaks . " FROM pricing WHERE
sku ='" . $code . "';";	

	my $sql_results = $Tag->query( {sql => $sql, hashref =>
'price_results' } );
		
	my $out = ref($sql_results);
			
	return $out;
}
EOR

The inline perl returns 'ARRAY' as it should and the usertag returns ''.
There are no errors in the error log, however it appears that the call
to $Tag->query is not working in the usertag.

I'm not too sure where to go from here, all of my tests show the code
working inline, but fail as a usertag without violating safe
constraints.  Any ideas?

Thanks!
-Ron

P.S. Thanks for your suggestions with the initial problem, I think this
way will be the best once I figure out why it does not work in a
usertag.