On 2/8/06, Herschel <[EMAIL PROTECTED]> wrote:
> Sara wrote:
>
> > Using this query in my Perl Script to find the Category title from the
> > database given as:
> > C_and_C++/Forums
> > C_and_C++/Codes
> > C_and_C++/Sites
> > etc.
> > my $sql = qq(SELECT CAT_TITLE, FROM categories WHERE CAT_TITLE REGEXP
> > '^C_and_C\\+\\+/[a-zA-Z|_]+\$' )
> >
> > $query = $dbh -> prepare ($sql) or die "Couldn't prepare statement: "
> > . $dbh->errstr;
> >
> > $query->execute();
> >
> > And when the query is executed, I am gettin' error:
> > "DBD::mysql::st execute failed: Got error 'repetition-operator operand
> > invalid' from regexp"
> > I am using double \\ in front of + as advised on the link given below
> > but still gettin' error, any solution to it?
> >
> > http://213.136.52.42/bug.php?id=399
> >
> See Clarkson's response on the grep.  What bothers me is the WHERE
> clause, which seems to be lacking an equivalence or other matching
> condition.  That is it equal to or LIKE (where the latter requires a
> wild card character is the databases I have used).
>

REGEXP is the matching condition. It's a synonym for RLIKE provided,
for some reason that's never been entirely clear to me, to provide
mSQL compatibility. You could rewrite as

    WHERE
        cat_title RLIKE '^C_and_C[+][+]/[a-zA-Z|_]+$'
        ...

As for the regex itself, check Appendix G of the MySQL manual
(http://dev.mysql.com/doc/refman/5.1/en/regexp.html) for the syntax.
The regex in question is being interpreted by MySQL's regex engine,
not Perl's, as the error message shows--the error is being propagated
from MySQL's REGEXP operator.  MySQL uses POSIX re, not Perl re or
even PCRE. The differences may be significant. If Clarkson's
recommendation doesn't fix the problem, you'll probably want to talk
to a MySQL list.

The best course of action for debugging SELECT queries is to debug
them at the mysql client command line. Once you have a select
statement that works, then import it into the perl script. Trying to
debug the SQL and the Perl at the same time is a recipe for confusion.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to