Missing expression in convert function - oracle

I am trying to use convert function to convert date field to varchar but it keep giving missing expression error.
My Query:
select INVENTORY_ITEM_ID,
convert(varchar(20), IMPLEMENTATION_DATE,110)
from apps.mtl_item_revisions
where INVENTORY_ITEM_ID=21928;
gives error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action: Error at Line: 97 Column: 35

The following line is Microsoft SQL Server syntax, not Oracle syntax:
convert(varchar(20), IMPLEMENTATION_DATE,110)
It doesn't matter what kind of database driver you use, or who wrote it. The query is being sent to Oracle with SQLServer syntax and Oracle is giving the error. (Also, while it might be required in a query tool, be wary of terminating oracle SQL statements with semicolon; in some languages (e.g. C#, or dynamic SQL within PL/SQL) you may get an unexpected character error.)
Change your SQL to this:
select INVENTORY_ITEM_ID,
to_char(IMPLEMENTATION_DATE, 'mm-dd-yyyy') as IMPLEMENTATION_DATE
from apps.mtl_item_revisions
where INVENTORY_ITEM_ID=21928
That's the ORacle equivalent of SQLServer 110 date format

Related

Oracle command gives error while inserting - C#

I'm executing a regular Oracle insert query, I don't know why this error happens, any clue?
Insert query is a bit complicated, can't paste it here
is ParamInfo893e67a5-d0ab-4489-b8b3-4f5b05dbdb3d mean that the issue is because of Guide?
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at Oracle.ManagedDataAccess.Client.OracleParameter.set_Size(Int32 value)
at ParamInfo893e67a5-d0ab-4489-b8b3-4f5b05dbdb3d(IDbCommand , Object )

Getting max value from a Date column in Oracle using max()

I am trying to query the latest date from table with a column DATE.
My expression is as follow:
SELECT MAX(DATE) FROM table_name;
I received back error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Any idea what is the issue? please help.
DATE is a reserved word and cannot be used as an unquoted identifier as the SQL engine expects it to be either a data-type or as part of a date literal such as DATE '1970-01-01'. In your case, the SQL engine expects DATE to be followed by the literal of the date-literal (e.g. '1970-01-01') but that does not happen which is why it complains about a missing expression.
If you have a column named DATE then you should:
Change it to a different name; or
If that is not possible, always use a quoted identifier whenever you refer to the column (which requires double quotes around the identifier and the correct case to be used).
SELECT MAX("DATE") FROM table_name;

How can I get this syntax to work in Oracle?

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
simplest repo, how can I get this to work in Oracle?
SELECT 'X' NewColumn, * FROM MyTable;
I get
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action: Error at Line: 1 Column: 23
My actual issue is:
I'm using an ETL tool that allows automapping if I use SELECT *
I want to use ORA_ROWSCN to implement incremental loads
So the real query I'm running is:
SELECT ORA_ROWSCN, * FROM MyTable;
I get the same error for this
The syntax is valid if you alias the table and the *.
SELECT ORA_ROWSCN, t.* FROM MyTable t;
No idea whether your ETL tool knows how to do that. Of course, you could always create a view vw_table that runs this select and then use the view in the ETL tool.

Error, invalid number Jasperstudio and Oracle 12c

In the following SQL:
select cast(parvalor as float) valor from parametros where parid = 26
I want to get the data in decimal, use TO_NUMBER and CAST (XX AS FLOAT) but it does not work.
This query runs in ORACLE 12c and works normal, but when I execute it in JasperStudio 6.3, I get
error ORA-01722: invalid number.
I really have no idea where the error is, please help.
Ok, changing data decimal "," to ".", jasper recognized query, but in oracle no is functional, what is the problem?

Numeric or value error: character string buffer too small

I am having trouble with this simple query in oracle application express and am getting this error:
Query cannot be parsed, please check the syntax of your query.
(ORA-06502: PL/SQL: numeric or value error: character string buffer
too small)"
SELECT E.EQUIPMENTID, E.EQUIPMENTDESCRIPTION
From EQUIPMENT as E
left outer join EQUIPMENT_CHECKOUT as EC 
on E.EQUIPMENTID = EC.EQUIPMENTID
WHERE EC.EQUIPMENTID is null
I think the error might be misleading in this case. You don't include AS when specifying table aliases, i.e.:
SELECT E.EQUIPMENTID, E.EQUIPMENTDESCRIPTION
From EQUIPMENT E
left outer join EQUIPMENT_CHECKOUT EC
on E.EQUIPMENTID = EC.EQUIPMENTID
WHERE EC.EQUIPMENTID is null
BTW: in Apex, you can try SQL statements in the SQL Commands window (in SQL Workshop) which usually gives better syntax error info.

Resources