Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Table and Functions

Quote Reply
Table and Functions
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:

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.
Subject Author Views Date
Thread Table and Functions LanceWilson2 3546 Jan 5, 2003, 10:20 PM
Thread Re: [LanceWilson2] Table and Functions
604 3465 Jan 6, 2003, 10:28 AM
Thread Re: [TheStone] Table and Functions
LanceWilson2 3454 Jan 6, 2003, 12:54 PM
Thread Re: [LanceWilson2] Table and Functions
604 3450 Jan 6, 2003, 1:14 PM
Thread Re: [TheStone] Table and Functions
LanceWilson2 3452 Jan 6, 2003, 2:45 PM
Thread Re: [LanceWilson2] Table and Functions
604 3455 Jan 6, 2003, 2:52 PM
Post Re: [TheStone] Table and Functions
LanceWilson2 3457 Jan 6, 2003, 3:24 PM