[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] Single-Quotes in SQL
On Wed, 10 Jul 2002, Jay Banyer wrote:
> INSERT INTO tablex VALUES('Jay''s data', 'blah');
> It appears that I will have to search every single value for
> single-quotes and insert an additional single-quote before each one.
> Can anyone suggest an alternative?
For such values, you could always URL encode them.
No, I'm serious (it does get the job done; but you'd have to encode and
decode all strings -- or somehow keep it consistent). Although
substituting the single-quote (i.e. ' changed to %) is a more efficient
encoder, the most appropriate is probably replacing the single-quote ('
changed to '').
Regardlessly of which method you use, when you search, you'd have to
encode the search string in exactly the same way, so you may as well code
a helper function to do it.
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to email@example.com.
If you are having trouble, ask firstname.lastname@example.org for help.