On Wed, 2 Apr 2003 13:51:01 -0700, you (Gregg Allen <[EMAIL PROTECTED]>)
wrote:

>
>Can someone tell me why this statement works interactively but not from 
>a perl script?
>
>
>MySQL>   SELECT * FROM MESSAGES WHERE pkey = $pkey\G ;
>
>This prints the output in a very nice, readable format.
>
>but:
>
>my $query = " SELECT * FROM MESSAGES WHERE pkey = $pkey\\G ";
>
>$sth->prepare($query);
>
>$sth->execute();

The execute command does what \G does in an interative SQL-client
shell, so only use your plain SQL-syntaks.

I would also suggest use of binding:

my $query = " SELECT * FROM MESSAGES WHERE pkey = ?";
$sth->prepare($query);
$sth->execute($pkey);

If this is done by using DBI-module, please read about binding in that
documentation.

-- 
mvh/Regards
K�re Olai Lindbach

Reply via email to