Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Quote mark in string messing up mySQL INSERT

by tadman (Prior)
on Dec 12, 2002 at 15:18 UTC ( [id://219339]=note: print w/replies, xml ) Need Help??


in reply to Re: Quote mark in string messing up mySQL INSERT
in thread Quote mark in string messing up mySQL INSERT

There's a problem with MySQL and placeholders which I discovered in Re^2: DBD::mysql Unusual Behavior. The only sure-fire way to work around it is to ensure that your string values are string values. In short, this means that the internal type of the variable is set correctly.

If the first variable sent into the placeholder is an integer, subsequent calls using the same statement handle might fail on string data. Here, this is just a do() call, so you're probably okay. If you use prepare() and more than one execute() you can encounter problems.
sub insertAttribute { my ($serverID, $featureID, $value) = @_; my $sqlINS = "INSERT INTO attribute VALUES (?,?,?)"; $dbh->do($sqlINS, {}, "$serverID", "$featureID", "$value"); }
Of course, this might depend on the version of DBD::mysql that you use.

Replies are listed 'Best First'.
Re: Re^2: Quote mark in string messing up mySQL INSERT
by paulbort (Hermit) on Dec 12, 2002 at 16:22 UTC
    Also, last I checked, you CANNOT use placeholders with the version of DBD::Sybase that works with FreeTDS and MS-SQL. :(
    --
    Spring: Forces, Coiled Again!
      Or to be specific, FreeTDS hasn't yet implemented the API calls that are needed to handle placeholders at the protocol level.

      It should be noted that although Sybase and MS-SQL both "speak" the TDS protocol the two companies have diverged significantly in the last few years, and handling of placeholders is different with MS-SQL (TDS version 7 and 8) compared to Sybase (TDS version 5).

      Among other things Sybase has implemented a capability based negotiation functionality when the client and server first connect, which makes the protocol extensible without necessarily having to rev the protocol version. This is why DBD::Sybase calls ct_capability(CS_CAP_REQUEST, CS_REQ_DYN) to check if the server is capable of handling "dynamic" requests (i.e. placeholders). As this request doesn't exist in the MS version of the protocol the FreeTDS folks will have to emulate it (not too hard, probably).
      But it's implementing the rest of the functionality that is needed to handle this stuff in a manner consistent with the way DBD::Sybase expects it to work that I think could be tricky.

      I've been thinking for a while that it might be a good idea to create a DBD module that is more specific to FreeTDS and MS-SQL, instead of (or in addition to) trying to shoehorn DBD::Sybase into this function.

      Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://219339]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-18 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found