Gossamer Forum
Home : Products : DBMan SQL : Development, Plugins and Globals :

Problem in the globa .. extracting data from databasel

Quote Reply
Problem in the globa .. extracting data from databasel
Hi,

I am new to DBMan SQL.. have started using it just few days back . ,, I wrote a global to extract data from the database and it gave me an error

here is the global

sub {
use GT::Date qw/:all/;
my($tags) = shift;
my $accountid = $tags->{AccountID};
my $table33 = $DB->table(\'tblClients\');
my $sth33 = $table33->select ([\'ClientID\'], {AccountID => $accountid});
$sth33->execute();

my $clientid = $sth33->fetchrow();
my $output= $clientid;
return $output;
}


the error message is :

Unable to compile 'inv_po'. Reason: Can't find string terminator "'" anywhere before EOF at (eval 18) line 4.



Can somebody help me with this . please .. also i would like to know ... what exactly is the use of putting

"my" before the variables
Quote Reply
Re: [sdsouza] Problem in the globa .. extracting data from databasel In reply to
Try replacing the following two lines -

use GT::Date qw/:all/;
my($tags) = shift;


with just one line -

my $tags = GT::Template->tags;

Also remove the "\" and add " ' " in the following -

my $table33 = $DB->table(\'tblClients\');
my $sth33 = $table33->select ([\'ClientID\'], {'AccountID' => $accountid});

Try the above first and let me know if it works. If not, you could also try the following (which is how I would usually write the global) -

sub {
my $tags = GT::Template->tags;
my ($clientid) = $DB->table('tblClients')->select({'AccountID' => $tags->{AccountID} }, ['ClientID'])->fetchrow_array();
return $clientid;
}

"my" is used to declare a variable before it is used. It only needs to be declared once. If you don't declare it you will get an error.

Hope that helps.

Simon.