I'm trying to accomplish the following query using a global and return the result to be printed in my template:
SELECT db_data.Variable_A
FROM db_data
WHERE db_data.ID = 'Variable_B'
I want to pass in Vaiable_A (the column that the data I want to retrive is in) and Variable_B, which is a currently available template variable. Variable_A will be a string. This is the global code:
my $tags = shift;
my $db_column = $tags->{db_column};
my $id = $tags->{LOTID};
my $table = $DB->table('db_data');
my $sth = $table->select ( { db_column=> $id } );
return $sth;
}
SELECT db_data.Variable_A
FROM db_data
WHERE db_data.ID = 'Variable_B'
I want to pass in Vaiable_A (the column that the data I want to retrive is in) and Variable_B, which is a currently available template variable. Variable_A will be a string. This is the global code:
Code:
lotdatasub { my $tags = shift;
my $db_column = $tags->{db_column};
my $id = $tags->{LOTID};
my $table = $DB->table('db_data');
my $sth = $table->select ( { db_column=> $id } );
return $sth;
}
Code:
It is called in the template with the following code: <%lotdata('Title1',LOTID)%> where Title1 is Variable_A and LOTID is the current template variable. I want the data in column 'Title1' in the database db_data to be printed where I call the global. I get the following error: Can't use string ("Title1") as a HASH ref while "strict refs" in use at (eval 17) line 3.Any help would be appreciated. Thanks!