So I discovered late last night that instead of fiddling with the existing "code" (and thus breaking future upgrades) that I have within my system I can just create my own and call it from the templates. For instance In the Template I do this:
<%set Carrier = Dbsql::custom::GetCarrier%>
and in the file called "custom.pm" (which is in the Dbsql directory) I create a file with this inside it:
#--------------------------------------------------------------------
# Lookup data in another database.
#
my $self = shift;
my $id = 'Wilson Lance';
my $table = $self->{sql}->table('Patients');
my $carrier = $table->get ('$id', 'HASH', ['Carrier']);
return $carrier;
}
Which should work as long as I can get the function to work. Here is where I need the help. I have an SQL table called "Patients" (which is outside of the table I am currently working on in my template, by the way) and I want to return the value within the column "Carrier". Sounds simple but I am doing something wrong here, what is incorrect? I get the error: "Can't call method "table" on an undefined value ..."
Another part of the puzzle, but less important, is how do I transfer a Variable inside the template back to this script? In this example, I want to transfer the variable "id" from the template (which I hard coded above for testing purposes)?
I need to get this project done and I'm ALMOST there, any help would be appreciated.
Code:
<%set Carrier = Dbsql::custom::GetCarrier%>
and in the file called "custom.pm" (which is in the Dbsql directory) I create a file with this inside it:
Code:
sub GetCarrier { #--------------------------------------------------------------------
# Lookup data in another database.
#
my $self = shift;
my $id = 'Wilson Lance';
my $table = $self->{sql}->table('Patients');
my $carrier = $table->get ('$id', 'HASH', ['Carrier']);
return $carrier;
}
Which should work as long as I can get the function to work. Here is where I need the help. I have an SQL table called "Patients" (which is outside of the table I am currently working on in my template, by the way) and I want to return the value within the column "Carrier". Sounds simple but I am doing something wrong here, what is incorrect? I get the error: "Can't call method "table" on an undefined value ..."
Another part of the puzzle, but less important, is how do I transfer a Variable inside the template back to this script? In this example, I want to transfer the variable "id" from the template (which I hard coded above for testing purposes)?
I need to get this project done and I'm ALMOST there, any help would be appreciated.