I have issue in running the following sql:
update personal_view test set session_state="<script type="text/javascript">
alert (mstrApp.sessionState);
</script>"
I know it is because of the double quotes within the double quotes and symbols like ; / < and > in the sql.
Any idea on how to fix this issue?
Try:-
update personal_view test set session_state='"<script type="text/javascript">'
In most SQL dialects strings are wrapped in single quotes double quotes have no special meaning inside a string.
Related
Why this query is not working:
UPDATE country SET timezones="[{"zoneName":'Asia\/Kabul',"gmtOffset":16200,"gmtOffsetName":'UTC+04:30',"abbreviation":'AFT',"tzName":'Afghanistan Time'}] " where name='Afghanistan'
Error I get:
ERROR: syntax error at or near "zoneName"
LINE 1: UPDATE country SET timezones="[{"zoneName":'Asia/Kabul',"gm...
^
SQL state: 42601
Character: 34
the issue with your SQL statement is that the literal string you are trying to set timezones to contains improperly formatted escape characters. if you wanted to avoid that first error you can double up on quotes like timezones="[{""zoneName"": ...
you can go to the link to see more about string formating in SQL. good luck!
You're trying to update the value wrapping the string in quotes. You need to wrap the string in single quotes timezones='[{"zoneName":'Asia...}]'
However, to TitledTeapot's point, you will also have to escape the existing single quotes in your string, so you'd end up with something like this:
'[{"zoneName":''Asia\/Kabul'',"gmtOffset":16200,"gmtOffsetName":''UTC+04:30'',"abbreviation":''AFT'',"tzName":''Afghanistan Time''}]'
I am getting a syntax error in a PostgreSQL query. I am working on a project developed in YII1, I am getting an error
CDbCommand failed to execute the SQL statement: SQLSTATE[42601]:
Syntax error: 7 ERROR: syntax error at or near "s" LINE 1: ...OT NULL
AND sub_heading like '%Women and Children's Voices%'.
As you can see above, I am using the like operator in single quotes, and in the string there is another single quote (Children's). So PostgreSQL is throwing me an error. Please provide me a solution to escape the string.
You can escape a single quote in a string by using another single quote (i.e., '' instead of '. Note that these are two ' characters, not a single " character):
sub_heading LIKE '%Women and Children''s Voices%'
-- Here -----------------------------^
You should use the format function to construct the SQL statement, using the %L placeholder for the pattern.
I solved this problem by replacing the single quote with double quotes using PHP. Here is the code
There is a variable $var with value Women and Children's Voices. I replace that single quote using the str_replace() function.
$var = str_replace("'", "''", $var);
I have a string which i am getting
#set($locator=$dataElement.getLocator().get(0))
#set($selector = $locator.getSelector())
$selector is string type and it contains double quotes as well
when i am calling
executor.click(new Params("$selector",BY.$By));
selector have double quotes, which needs to be replaced with single quotes.
i tried with replacing but it is giving error
i referred question
Escaping quotes in velocity template
But this also don't solved my purpose
example
$selector can be something like
a[#href="somelink"]
and i want that to changed to
a[#href='someLink']
For velocity
$selector.replaceAll('"',"'")
replaces " with '
so something like:
executor.click(new Params("$selector.replaceAll('"',"'")",BY.$By));
this works fine
I have been struggling with this query for a while. This runs fine with H2 but I don't know why it is throwing this error in Oracle:
18:09:02,1 [pool-5-thread-1] ERROR SqlExceptionHelper - ORA-00907: missing right parenthesis
Any help or suggestions would be highly appreciated.
When I formatted your code I noticed that you had double single quotes around the string PRESHIP_FIN_CONVERSION_TENOR.
Change this:
WHERE efd.ATTRIBUTE_NAME = ''PRESHIP_FIN_CONVERSION_TENOR''
To this:
WHERE efd.ATTRIBUTE_NAME = 'PRESHIP_FIN_CONVERSION_TENOR'
In both subqueries.
WHERE efd.ATTRIBUTE_NAME = ''PRESHIP_FIN_CONVERSION_TENOR''
Shouldn't the value be enclosed within single quotation marks? Do that at both places in the query.
In Oracle, you use single quotes for strings.
Hi I am facing a problem with the like command in SQL,
I want to search for special characters within a column .
The special characters are a single quotation mark ' and { and }..
I have tried placing these special characters under [] but still it doesn't work for '
I have also used the except option but that was also of no help..
Waiting for a response soon
When you specify a value which has single quote, you need to double it.
SELECT *
FROM dbo.Northwind
WHERE Summary LIKE 'single''quotes%'
Try using this-
select * from <table> where <column> like '%''%'
SQL Server escaping is a pain because there are various ways to escape characters, each with different meaning and use case.
A single quote is escaped with another single quote: WHERE myfield LIKE '%''%'.
The general solution is to escape the special character like so:
SELECT .... WHERE my_column like '%\'%' ESCAPE '\'