Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Unable to compile ... home.pm line 1044

Quote Reply
Unable to compile ... home.pm line 1044
I've been trying to get a simple global routine (named "wax_count") to work with with DBSQL which I added using the Templates Global form.

Here's the code:
*****************
sub {
my $wax_db = $DB->table ('wax');
my $count = $wax_db->total;
return $count;
}
****************

in my template I put the tag <%wax_count%> (home.html), which generates the unable to compile error.

What am I doing wrong? I can get it to print text all day but as soon as I try to query a table I fail (at least I'm consistent).

Thanks,
Earl


Quote Reply
Re: [Super] Unable to compile ... home.pm line 1044 In reply to
Is total a valid object method?

What do you want the code to do?


Quote Reply
Re: [RedRum] Unable to compile ... home.pm line 1044 In reply to
I want it to return a record count.
Quote Reply
Re: [Super] Unable to compile ... home.pm line 1044 In reply to
Don't quote me on this but wouldn't you need:

Code:
sub {
my $wax_db = $DB->table ('wax');
my $count = $wax_db->count();
return $count;
}
Quote Reply
Re: [RedRum] Unable to compile ... home.pm line 1044 In reply to
Still generates the same error. I've tried other queries that were used in the previous SQL version of DBMAN but I keep getting the same error in home.pm

I only used this code (which I took from the Links board) to try to get ANYTHING to work.

Thanks,
Earl


Quote Reply
Re: [Super] Unable to compile ... home.pm line 1044 In reply to
Quote:
Still generates the same error. I've tried other queries that were used in the previous SQL version of DBMAN but I keep getting the same error in home.pm

I too have tried unsuccessfully to get any sort of query related global to work in DBSQL...It keeps returning the same "cannot compile" error that you are getting. Just like you, text only globals work fine...I hope you get an answer to this one as I am waiting to convert my site over to DBSQL 2.01 once this is resolved.

easy does it
Quote Reply
Re: [Bearwithme] Unable to compile ... home.pm line 1044 In reply to
Hi,

Just put the below scripts into template global:

sub {
my $tags = shift;
my $sql = $tags->{home}->{sql};
my $sth = $sql->table('Sample')->select();
return $sth->rows;
}

And then, you have to add <%function_name%> in template file.

Cheers,
TheStone.


B.

Last edited by:

TheStone: Oct 31, 2001, 2:40 PM
Quote Reply
Re: [TheStone] Unable to compile ... home.pm line 1044 In reply to
Hmm you must be really digging around in the code - it can't have been available for that long and you have mastered it already :)

Last edited by:

RedRum: Oct 31, 2001, 2:48 PM
Quote Reply
Re: [Super] Unable to compile ... home.pm line 1044 In reply to
Hi,

We will release 2.0.2 today which fixes a bug in plugins and will fix this. We'll also put up a sample plugin for people.

To fix this, basically, edit admin/Dbsql/Home.pm and on line 1197 change:

my $code = eval $GLOBALS->{$template_set}->{$key};

to:

my $code = eval "package Dbsql; $GLOBALS->{$template_set}->{$key}";

and it should work as expected.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Unable to compile ... home.pm line 1044 In reply to
Quote:
To fix this, basically, edit admin/Dbsql/Home.pm and on line 1197 change:
Code:
my $code = eval $GLOBALS->{$template_set}->{$key};
Code:

to:

Code:
my $code = eval "package Dbsql;
$GLOBALS->{$template_set}->{$key}";

and it should work as expected.

It still doesn't work and generates a "cannot compile" in home.pm line 1151 (which in my editor is the same line for the replacement code above)

easy does it
Quote Reply
Re: [Bearwithme] Unable to compile ... home.pm line 1044 In reply to
I also am still receiving the same error after making the modifications.

Thanks,
Earl
Quote Reply
Re: [RedRum] Unable to compile ... home.pm line 1044 In reply to
In Reply To:
Hmm you must be really digging around in the code - it can't have been available for that long and you have mastered it already :)

Must have missed the 'Staff' title? Wink

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Bearwithme] Unable to compile ... home.pm line 1044 In reply to
Can either of you send a message to support-dbsql@gossamer-threads.com with admin access info (assuming I can modify Home.pm via FileMan) and I'll take a look today.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Unable to compile ... home.pm line 1044 In reply to
HA!

What an idiot - I wondered why TheStone knew so much :)
Quote Reply
Re: [Alex] Unable to compile ... home.pm line 1044 In reply to
Quote:
We will release 2.0.2 today which fixes a bug in plugins and will fix this

Never enough hours.. We'll have to release this tommorrow.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Unable to compile ... home.pm line 1044 In reply to
Quote:
Can either of you send a message to support-dbsql@gossamer-threads.com with admin access info (assuming I can modify Home.pm via FileMan) and I'll take a look today.

I'd love to Alex, but my client is on a corporate intranet sitting behind a big bad firewall.

OOPS...Light comes on and brain is now engaged - I have set up a test domain outside the firewall and will send you the info forthwith...




easy does it
Quote Reply
Re: [TheStone] Unable to compile ... home.pm line 1044 In reply to
 
For performance reasons in large tables i would recommand
Code:
my $count = $sql->table('Sample')->count();
This should provides the same result as
Code:
my $sth = $sql->table('Sample')->select();
return $sth->rows;
without the need to slurp in the complete table.


Quote Reply
Re: [Alex] Unable to compile ... home.pm line 1044 In reply to
UnsureWe're waiting to downloadCrazy But still not thereUnsure


TheFox