Subject | Single/Double chars in insert statements... |
---|---|
Author | phil_hhn |
Post date | 2004-10-08T01:26:02Z |
Hi, this is a very basic question which I should know the answer to... :-[
A normal insert statement is something like:
insert into MyTable (SomeString) values ('The house of John')
How do you do the insert when there's an apostrophe in the string (eg
"John's House")? I can't write:
...values ('John's House')
Because the apostrophe in the middle stuffs things. I think in
SQL-server you can use a double (two) apostrophe, but that's probably
a SQL-server hack?
You can't put the String in double quotes, eg:
...values ("Pineapple Drink")
(ignoring the apostrophe in that case) because Firebird says column
unknown: "Pineapple Drink".
(Is this particular to Firebird, or the explicitly the behaviour
recommended by the SQL standard?)
Sorry, did a google search - there are countless sites describing the
insert statement and syntax, but in none of them did I see
_explicitly_ mentioned that single quotes only are accepted (although
they all show single quotes in the syntax).
This seems like such a newbie question :-)
[In all current cases where we have single quotes within Strings, we
just happen to be using prepared statements, and you can simply pass
any String - including those containing single quotes - to
PreparedStatement.setString(...)].
TIA...
A normal insert statement is something like:
insert into MyTable (SomeString) values ('The house of John')
How do you do the insert when there's an apostrophe in the string (eg
"John's House")? I can't write:
...values ('John's House')
Because the apostrophe in the middle stuffs things. I think in
SQL-server you can use a double (two) apostrophe, but that's probably
a SQL-server hack?
You can't put the String in double quotes, eg:
...values ("Pineapple Drink")
(ignoring the apostrophe in that case) because Firebird says column
unknown: "Pineapple Drink".
(Is this particular to Firebird, or the explicitly the behaviour
recommended by the SQL standard?)
Sorry, did a google search - there are countless sites describing the
insert statement and syntax, but in none of them did I see
_explicitly_ mentioned that single quotes only are accepted (although
they all show single quotes in the syntax).
This seems like such a newbie question :-)
[In all current cases where we have single quotes within Strings, we
just happen to be using prepared statements, and you can simply pass
any String - including those containing single quotes - to
PreparedStatement.setString(...)].
TIA...