It's possible that $stt is empty in some of the concatenations. A couple of minor style issues might clear it up.
Otherwise, it depends a lot on what's coming back from the database. Without seeing that, it's hard to know what the trouble is. As a side note, I personally wouldn't use this for such a thing. It's very hard to control what variables are in scope and accessible when you pull information out of a database like this.
There's probably a better way. If you describe the situation in SoPW, you'll probably get two or three alternate ideas that aren't as fragile.
sub VWP_RunQuery {
my ($QueryRef, @Params) = @_;
if ($QueryRef) {
VWP_Log(5, "Running query $QueryRef...");
my $stt = "select q.FromVal, q.OrderVal, q.SelectVal, q.WhereV
+al " .
"from VWPQuery q, VWPQueryRef qr where q.Query=qr.Query and "
+.
"qr.DBType = ? and qr.Query = ?";
my $Return = VWP_SQL($stt, ($Session::DBType, $QueryRef));
if (@$Return) {
my $OrderVal = $Return->[0]->{OrderVal};
$stt = "select " . $Return->[0]->{SelectVal} . " from " .
$Return->[0]->{FromVal};
if ($Return->[0]->{WhereVal}) {
my $WhereVal = eval "qq/$Return->[0]->{WhereVal}/";
$stt .= " where " . $WhereVal;
}
if ($OrderVal) {
$stt .= " order by" unless $OrderVal =~ /^order by/i;
$stt .= " $OrderVal";
}
return VWP_SQL($stt, @Params);
}
}
VWP_StrMessage(1, 13, $QueryRef);
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.