ORA-01741: illegal zero-length identifier - sql

Hi I am using a delete query in my shell script and I am facing this issue.
delete from WHITELIST_CLI where filecode like'%Line_Index_condense%';
Error:
ERROR:
ORA-01741: illegal zero-length identifier

Here is some information on the error:
ORA-01741: illegal zero-length identifier
Cause: An attempt was made to use two double quotes ("") as an
identifier. An identifier must be at least one character long.
Your query has nothing of the sort. This may be an interaction between ksh and Oracle. Or you may have used double quotes when you mean single quotes. Or, you may have oversimplified the query when you posted the question. Or another query may be the issue.
Here is a simple example of the error on SQL Fiddle.

Related

Postgres solving a syntax error caused by a dash (-)

I am trying to query from a database called physionet-data.mimiciii_clinical.diagnoses_icd
PostgresSQL returns the following error message:
quan.sql:273: ERROR: syntax error at or near "`"
LINE 132: from `physionet-data.mimiciii_clinical.diagnoses_icd` icd
I think it is caused by the dash. If I change the `for ' the same error comes up
quan.sql:273: ERROR: syntax error at or near
"'physionet-data.mimiciii_clinical.diagnoses_icd'"
Any clue on how to fix that?
You would need to quote that schema name, using double-quotes:
select ...
from "physionet-data".mimiciii_clinical.diagnoses_icd
Note that quoting an identifier makes it case-sensitive. You would need to ensure that the character case the schema was created with matches the one you are using here.
Using identifiers that require quoting is not a good idea in general; as you are fiding out, this requires quoting them every where you use it later on. If that's not too late, I would recommend changing the schema name to a name that does not require quoting.

AS400 - Token "!" not valid

I'm running a SQL query using RUNSQL into a CL program. This query is a basic SELECT statement and uses the exclamation mark to concatenate strings.
For years until yesterday, it worked fine. Now, out of nowhere, I've got a SQL0104 message displaying Token '!' not valid every time I run the program.
If I run the query manually using STRSQL, it works.
Did this occur to someone ?
Best regards.
DB2's operator for string concatenation is actually the double pipe ||.
The documentation says:
Use the concatenation operator (||) to join two values of an expression into a single string. In some non-English, single-byte character sets, the || can display as !! (exclamation marks) or other special characters.
So your issue may be caused by a change in the character set of your client. Just use the standard operator, and your code will work regardless.

How would I fix these "ORA-00933: SQL command not properly ended" "ORA-00923: FROM keyword not found where expected" errors?

This Statement:
SELECT id, units, cost FROM inventory_list WHERE cost <= 20;
Gives me:
ORA-00923: FROM keyword not found where expected
While this statement:
SELECT * FROM items WHERE ilt_id = 'il010230126' OR ilt_id = 'il010230128';
Gives me:
ORA-00933: SQL command not properly ended
Not sure about this and may be version dependent (below link is for oracle 10g... but you can see on this site
https://docs.oracle.com/cd/B19306_01/em.102/b40103/app_oracle_reserved_words.htm
That cost is an oracle reserved keyword, so it is not wise to use it as a column name.
If you have no control of the table I think you may be able to surround it in double quotes eg select "COST" to avoid oracle picking it up as a reserved word.
By default Oracle creates fields in uppercase so the field name will need to be in uppercase unless when the table was created it was forced into different case by surrounding it in Quotes.
Check that you don't have invisible characters in your file and that you're using the right encoding. I sometimes accidentally introduce them because I have a non english keyboard map and accidentally hit the wrong key combination.
Just type again one of your SQL statements and test them.

String with single quote in graphical calculation view HANA

We have HANA database with SPS 12 version.
We have graphical calculation view where we have created calculated column with 'if..else' logic. Below is the if else logic used -
if("COL1"='A'B','X','Y')
I am getting below error-
Invalid ExpressionSAP DBTech JDBC: [2048]: column store error: failed to set expression: [6968] Evaluator: syntax error in expression string; expected TK_RPAREN, parsing "if("COL1"='A'[here]B','X','Y')"
I have to check if COL1 has value A'B. I am not able to understand how we should handle single quote in Graphical Calculation view.
Best Regards
You can escape a single quote (') by using two single quotes (''). Note that this is not the double quote character ("):
if("COL1"='A''B','X','Y')
Change language from Column Engine to SQL
and Expression is:
if("COL1"='A''B','X','Y')

How can I solve ORA-00911: invalid character error?

I tried to execute an SQL INSERT with Toad for oracle:
INSERT INTO GRAT_ACTIVITY
(UUID, IP_ADRESS, SEND_MAIL, DATE_CREA, DATE_UPD, CREATOR, CENTER, ETAT, REQUEST)
VALUES('555-vgd9-pllkd-5513', '172.12.23.130', 'N', SYSDATE, SYSDATE, '1554', 'M18', 'I', 8842);
--COMMIT;
the GRAT_ACTIVITY table structure is as below:
CREATE TABLE CASH.GRAT_ACTIVITY
(
UUID VARCHAR2(64 BYTE) NOT NULL,
IP_ADRESS VARCHAR2(15 BYTE),
SEND_MAIL VARCHAR2(1 BYTE),
DATE_CREA DATE,
DATE_UPD DATE,
CREATOR VARCHAR2(4 BYTE),
CENTER VARCHAR2(4 BYTE),
ETAT VARCHAR2(1 BYTE),
REQUEST NUMBER
)
the error message:
ORA-00911: invalid character
Cause: identifiers may not start with any ASCII character other than letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain any
character other than a doublequote. Alternative quotes (q'#...#')
cannot use spaces, tabs, or carriage returns as delimiters. For all
other contexts, consult the SQL Language Reference Manual.
Action: None
How can I solve it?
The statement you're executing is valid. The error seems to mean that Toad is including the trailing semicolon as part of the command, which does cause an ORA-00911 when it's included as part of a statement - since it is a statement separator in the client, not part of the statement itself.
It may be the following commented-out line that is confusing Toad (as described here); or it might be because you're trying to run everything as a single statement, in which case you can try to use the run script command (F9) instead of run statement (F5).
Just removing the commented-out line makes the problem go away, but if you also saw this with an actual commit then it's likely to be that you're using the wrong method to run the statements.
There is a bit more information about how Toad parses the semicolons in a comment on this related question, but I'm not familiar enough with Toad to go into more detail.
Remove the semicolon (;), backtick (``) etc. from inside a query
Remove the semicolon ( ; ).
In oracle, you can use semicolon or not when u ran query directly on DB. But when u using java to ran a oracle query, u have to remove semicolon at the end.
If a special character other than $, _, and # is used in the name of a column or table, the name must be enclosed in double quotations.
Link
I encountered the same thing lately. it was just due to spaces when copying a script from a document to sql developer. I had to remove the spaces and the script ran.
I'm using a 3rd party program that executes Oracle SQL and I encountered this error. Prior to a SELECT statement, I had some commented notes that included special characters. Removing the comments resolved the issue.
I had the same problem and it was due to the end of line. I had copied from another document.
I put everythng on the same line, then split them again and it worked.
The option(s) to resolve this Oracle error are:
Option #1
This error occurs when you try to use a special character in a SQL statement. If a special character other than $, _, and # is used in the name of a column or table, the name must be enclosed in double quotations.
Option #2
This error may occur if you've pasted your SQL into your editor from another program. Sometimes there are non-printable characters that may be present. In this case, you should try retyping your SQL statement and then re-execute it.
Option #3
This error occurs when a special character is used in a SQL WHERE clause and the value is not enclosed in single quotations.
For example, if you had the following SQL statement:
SELECT * FROM suppliers
WHERE supplier_name = ?;
You probably copied and pasted the SQL from another source, and it screwed up something somehow. . . I don't know how or why lol.
Re-type your sql in whatever IDE you are using, and it should work.