On Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 using this code:
SELECT get_key( j.pos, t.value ) AS key,
j.value
FROM table_name t
CROSS APPLY JSON_TABLE(
t.value,
'$.*'
COLUMNS (
pos FOR ORDINALITY,
value PATH '$'
)
) j;
I found on Query json dictionary data in SQL doesn't work: it gives the error: ORA-00904: "T"."VALUE": invalid identifier but it works on fiddle.
Why doesn't this work on 19c?
Related
this is the query generated by an Odata Sql query generator and I am on Oracle 12c
SELECT ID
FROM MY_TABLE
WHERE (
NAME LIKE 'abc' = true
)
;
and the error it generates is
ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Error at Line: 4 Column: 14
Any ideas on how to fix the query ?
Thanks in advance
I know nothing about "Odata Sql query generator", but - if you want to fix this query, then it would be
select id from my_table where name like 'abc'
On the other hand, that's same as
select id from my_table where name = 'abc'
so perhaps you actually meant to use wildcards:
select id from my_table where name like '%abc%'
I am trying to select table from an oracle database using datastage.
In the ODBC Connector, If i do
select *
from Table_Name
I get this error -
'ODBC function "SQLNumResultCols" reportted: STATE=102:Native Error
Code = 0: Msg = [IBM(DataDirect OEM)][ODBC 20101 driver] 251'.
However if i use -
select cast(colA as varchar(50) as A,
cast(colB as varchar(50) as B
instead of
select *
from table_name
it works just fine. The data type of these columns is NVARCHAR2.
Is there a way to directly get it from
select *
from table_name
(there are about 20 columns in each of these tables)
Found a fix. Changed nvarchar parameter in odbc file
I am new to SQL and recently installed Oracle 11g. I read the post here on selecting all tables from user_tables. I'm trying to select a specific table and following some of the suggestions in the post does not appear to work.
The following executes fine and returns all tables available to me including a table named faculty_t:
select * from user_tables;
select * from dba_tables;
select * from all_tables;
desc faculty_t;
But I get error when I do the following:
select * from user_tables where table_name = FACULTY_T;
The first set of statements confirm that I do have a table named faculty_t. However, trying to select this table from user_tables, all_tables, or dba_tables does not appear to work for me right now. The error message reads something like:
ORA-00904: "FACULTY_T": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 208 Column: 8
Any thoughts? Thanks!
String literals in SQL are wrapped in '. So:
select * from user_tables where table_name = 'FACULTY_T';
When you did a desc faculty_t, the SQL engine knew that a table name was expected at that spot (the syntax expects a table name there). But in your select query, sql is just looking for the value of a column that happens to have a string data type, so you need to use the ' for a string literal.
I have a table (AKADMIN) with an XMLTYPE column which name is XML.
I would like to use the getClobVal() with this column.
select t.xml.getClobVal() /**/
, t.xml.getClobVal() --
, t.xml.getClobVal() as clobval
, t.xml.getClobVal()
from akadmin t where ROWID = 'AAAQc6AAIAAAADDAAA' ;
In the resultset the first 4 column give CLOB type, but the fifth column XMLTYPE. I have to type any comment or alias after getClobVal() to correct (CLOB) type of the result. Why?
Another issue, when I leave the alias of tablename:
select xml.getClobVal()
from akadmin t where ROWID = 'AAAQc6AAIAAAADDAAA' ;
It throws an ORA-00904 string: invalid identifier
Hmmm...
Does anybody have any idea?
Addition info about environment:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0;
PL/SQL Developer 10.0.5.1710
But a tried this in our Java apllication via OJDBC6 with same results
You should put xml in a brackets:
select (xml).getClobVal() from akadmin;
works for me
I have the following (example) query that I'm trying to run
SELECT some_field
FROM MY_VIEW
WHERE date_field >= TO_DATE('2011-06-22', 'yyyy-mm-dd')
When I run this in SQL*Plus, I get a set of results, when I try through JDBC (using java.sql.Statement) I get the following error: java.sql.SQLException: ORA-01722: invalid number.
To make it even stranger, the following code works through the JDBC:
select field_1
FROM MY_VIEW v1
WHERE field_2 != 'some value'
AND not exists (
SELECT field_1
FROM MY_VIEW v2
WHERE v1.field_1 = v2.field_1
and t1.timestamp < t2.timestamp
)
But the code below (which still works in SQL*Plus) doesn't (same ORA-01722 error):
select field_1
FROM MY_VIEW v1
WHERE field_2 != 'some value'
AND not exists (
SELECT field_1
FROM MY_VIEW v2
WHERE v1.field_1 = v2.field_1
and v2.field_2 = 'some value' -- Does not work with this line (same value as above)
and v1.timestamp < v2.timestamp
)
I'm running Java 6, connecting to Oracle 10g, and using the ojdbc14.jar. I think it's important to note that the view being queried (MY_VIEW) is a fairly complicated thing, including more then one field being casted from varchar to numeric. My current suspicion is that Oracle is creating a different, unworkable, execution plan for the jdbc query then for the SQL*Plus.
Any suggestions on what I should do from here?
Thanks.