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.
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'm having an issue matching regular expression in BigQuery.
REGEXP_REPLACE(tc.metadata->>'document_number', '\D', '', 'g') = m.document_number
However, BigQuery doesn't seem to like escape sequences for some reason and I get this error that I can't figure out:
Syntax error: Illegal escape sequence: \D
This code works fine, but BigQuery is unhappy with it and I can't figure out why. Thanks in advance for the help
You need to double escape the the character in BigQuery, as the first / will be consumed by JavaScript.
Try double escaping, e.g. \\D and that should work for you.
In [1] if you scroll down you can see the escaping sequences of standard SQL and none is \D, so as Ben P says, you need to double escape to have the backslash escaping sequence. I assume it's what is missing but if you could elaborate further your question the answer would be indeed more accurate.
[1] https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#string_and_bytes_literals
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've got a sql command in vba (access 2007) that's giving me errors, and I don't know why. Specifically, it says that there's a missing operator in the WHERE clause. I can't figure out what is missing. It's not the UDF ReplaceNotAN, which replaces the specific non-alphanumeric characters.
Any ideas for what's going on, and how to fix it? Everything I could find for similar error on the intertubez is irrelevant (mostly about the single vs double quotes issue - but clearly that doesn't apply here).
dcSql = "UPDATE table SET table.Customer=ReplaceNotAN(Customer)" & _
" WHERE table.Customer Like '*[-,.;:_'&=\/#]*';"
DoCmd.RunSQL dcSql
you have an additional single quote in the like phrase...
try it by doubling that one i think...
Like '*[-,.;:_''&=\/#]*';"
Why is the "From" seen as being in the wrong spot?
I had to change double quotes to single quotes in a query to get the query string to compile in the IDE while porting from Delphi to C#.
IOW, with SQL like this, that works in Delphi and Toad:
#"SELECT R.INTERLOPERABCID "ABCID",R.INTERLOPERID "CRID", . . .
...I had to change it to this for it to compile in Visual Studio:
#"SELECT R.INTERLOPERABCID 'ABCID',R.INTERLOPERID 'CRID', . . .
However, the SQL won't run that way - I get the "ORA-00923: FROM keyword not found where expected" err msg (both in Toad and when trying to execute the SQL in the C# app).
How can I get it both to compile and to run?
The quotes around your column aliases are giving it heartburn.
It appears that in the original case, the entire query is surrounded by double quotes, and the double quotes around the column aliases mess with those.
In the second case, Oracle is interpreting the single-quoted column aliases as strings, which throw it off.
In Oracle, you shouldn't need either: You should be able to just code:
#"SELECT R.INTERLOPERABCID ABCID,R.INTERLOPERID CRID, . . .
or, using the optional AS keyword:
#"SELECT R.INTERLOPERABCID AS ABCID,R.INTERLOPERID AS CRID, . . .
Hope this helps.
It is generally don't work if you have inline comments in query