[ic] SQL Statements within Usertags

Stefan Hornburg interchange-users@icdevgroup.org
Thu Jan 16 09:18:01 2003


On Thu, 16 Jan 2003 13:47:37 +0000
Rich Doughty <rich@opusvl.com> wrote:

> On 16 Jan 2003, Stefan Hornburg wrote:
> > > > 
> 
> <snip>
> 
> > > > To my knowledge, any query in the example above would work in your case, regardless of
> > > > the tables= and $Db parameter.
> > > 
> > > I'm getting an error $Db {products} undefined.
> > > keys (%Db) returns empty, although %Db *is* defined.
> > 
> > Please post your erroneous code.
> > 
> 
> Usertag is:
>     UserTag         testcase Interpolate  1
>     UserTag         testcase HasEndTag    1
>     UserTag         testcase Routine      <<EOR
>         sub {
>             my ($body) = @_;
>             my $rv;
>     
>             my $rs = $Db {products}->query ('SELECT * FROM products');
>     
>             return 1;
>         }
>     EOR
> 
> page contains:
>     [testcase] test [/testcase]
> 
> Results are:
>     Apache internal Server error - Premature end of script headers
> 
>     IC log shows "Runtime error: Can't call method "query" on an
>     undefined value at (eval 840) line 5."
> 
> database setup in catalog.cfg is:
>     Database         userdb            userdb.txt     __SQLDSN__
>     Database         userdb            USER           __SQLUSER__
>     Database         userdb            PASS           __SQLPASS__
>     Database         products          products.txt   __SQLDSN__
>     Database         products          USER           __SQLUSER__
>     Database         products          PASS           __SQLPASS__
> 
>     (where __SQLDSN__ is dbi::mysql::__DBNAME__::__DBPORT__)
> 
> IC v4.8.6
> Perl 5.8.0 (i386-linux-thread-multi - could this cause problems like it does
>             with locking?)
> 
> 
> all i want to do is reuse the DBI connection within my tag.

You need to put

[perl tables=products][/perl]

somewhere on your page before using your usertag or call the
above code within Autoload.

Bye
        Racke