Spring Auth Server JDBC implementation - error with Oracle DB BLOB [duplicate] - oracle

I have this query I am trying to run but I keep running into this error. I am trying to do a Where clause that compares the data (BLOB column) to :var2 which is a blob object.
Here is my code.
SELECT max(id)
INTO :var1
FROM table_name
where data = :var2;
Any suggestions to why I would be getting this ORA-00932 error?
I am comparing a blob to a blob column, shouldn't that be fine?
Thanks

They aren't simple types and you need to use a function to compare them.
SELECT max(id)
INTO :var1
FROM table_name
where dbms_lob.compare(data,:var2) = 0;

Related

cx_Oracle query JSON CLOB with 'LIKE'

I'm exploring cx_Oracle's JSON features within a CLOB. I have an index on the table that allows me to query for direct equality
SELECT * FROM mytable m WHERE m.jsonclob.jsonattribute = 'foo';
I'd like to be able to do the same thing with a LIKE statement.
SELECT * FROM mytable m WHERE m.jsonclob.jsonattribute LIKE 'foo.%';
This works for me with Oracle DB 12.2:
SQL> CREATE TABLE j_purchaseorder_b (po_document CLOB CHECK (po_document IS JSON)) LOB (po_document) STORE AS (CACHE);
Table created.
SQL> INSERT INTO j_purchaseorder_b VALUES ('{"userId":2,"userName":"Bob","location":"USA"}');
1 row created.
SQL> SELECT pob.po_document.location FROM j_purchaseorder_b pob where pob.po_document.location LIKE 'US%';
LOCATION
--------------------------------------------------------------------------------
USA
For reference check the Oracle JSON manual chapter Query JSON Data.
A side note: the JSON team like recommending BLOB for storage for performance reasons. Check the doc etc etc etc.

datastage error - odbc function "SQLNumResultCols"

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

Google Apps Script sync with oracle

I am trying to fetch the data from Oracle by Google Apps Script, I am able to fetch the data by simple queries like
Select * from EMP_TABLE
and
Select * from EMP_TABLE where EMP_NAME = "Dhananjay"
But I am not able to fetch the data by below query
Select * from EMP_TABLE where EMP_ID = 1100
in above case all other relational operators are working fine but equal to is not working for any numerical field.
Need help on fetching data from oracle by Google Apps script.
statement that I am using is :
var rs = stmt.executeQuery('SELECT * FROM EMP_TABLE WHERE EMP_ID = 1100');

The mystic getClobVal()

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

ORA-00932 inconsistent datatypes: expected - got BLOB

I have this query I am trying to run but I keep running into this error. I am trying to do a Where clause that compares the data (BLOB column) to :var2 which is a blob object.
Here is my code.
SELECT max(id)
INTO :var1
FROM table_name
where data = :var2;
Any suggestions to why I would be getting this ORA-00932 error?
I am comparing a blob to a blob column, shouldn't that be fine?
Thanks
They aren't simple types and you need to use a function to compare them.
SELECT max(id)
INTO :var1
FROM table_name
where dbms_lob.compare(data,:var2) = 0;

Resources