Perl and SQL
Shay Harding
plug-devel@lists.PLUG.phoenix.az.us
Tue Mar 25 12:49:02 2003
Actually there are a few things to look out for
here...
1. Just use: $text = $dbh->quote($text); to quote
anything MySQL doesn't like.
2. MySQL has a limit to the packet size it will
handle. Check that max_allowed_packet is big enough to
handle the query (default ~1MB). If your client code
(meaning the MySQL client code) is set to handle too
large a packet and the server is set to handle too
little, it could (it is pretty erratic) refuse to
perform the query.
Along the same lines, if you have a router set up to
route 2MB packets and max_allowed_packet is only
default settings you will run into problems. Make sure
your MySQL settings are == || > than the network
settings.
3. With the DBI MySQL driver, I don't think there is a
choice whether to query for the entire result set...
pretty sure it calls the underlying C API function
"mysql_store_result" by default in all instances,
rather than the "mysql_use_result".
Shay
--- Victor Odhner <vodhner@cox.net> wrote:
> Hi, Austin.
> I see nothing nasty about storing data in variables,
> especially if the data volume is large.
>
> I presume you are using DBI. It's very common to
> prepare a variable $sql that contains the whole
> query.
>
> In building such a string, use '' for quoting
> instead of "" to keep your escape characters.
>
> Vic
>
> --------
>
> Austin wrote:
>
> Hello Everyone,
> I am playing around with a little perl and SQL.
> I am having
> trouble doing an insert into a text field when the
> text is large and
> nasty. I am not sure how I can properly escape out
> the nasty characters.
> I have the text stored into a variable which I
> then use in my
> insert statement. This works fine with smaller
> stuff of course but it
> seems like an awfully unpleasant way of inserting
> LARGISH text. I am
> pretty new to both perl and SQL so I think I may be
> missing something
> (or do I have to escape out every reserved token
> before inserting?).
>
> Austin
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com