This is my blob statement
(xpath('/d:Invoice/d:InvoiceDetail/d:InvoiceLineItem/d:LineItemDescription/text()',
xml,
'{{d,http://www.m00.com/2019/01/RRRInvoice}}'))[1]::text as Line_ItemDescription,
Related
Bringing data from sql to oracle, I need to generate a query from Oracle where I am sending a query to sql to replace “ in a text field.
So, in sql I want to generate a query in oracle "SELECT REPLACE(TEXT, '“', '"'). It works fine if i run this directly on SQL server. But, since I need to store this query in Oracle first and then read it, oracle converts it to a junk "SELECT REPLACE(TEXT, '<somejunk>, '"'). Does anyone know how to make oracle literally take “. I tried ESCAPE and \ but nothing works
You need to concatenate two single quotes.
SELECT REPLACE( '"" - Double quotes to single quotes ', '""', ''''||'''') from dual;
I have a table which has a column with nested JSON data that I want to read for a query result. But the data type of column is VARCHAR and data inside is a JSON string with nested objects inside.
Now when I hit below query it works fine and gives me result,
select * from dataTable where regexp_like(metadata,'(*)"id":"33001"(*)');
Below is the metadata column of dataTable :
{"id":"33001",
"digits":"1234",
"requestId":"5d54-f6-48-8d-8155190",
"deliveryMethod":"ATT",
"messageStatus":"{\"status\":[
{\"tokenId\":\"Zktx\",\"deliveryStatus\":\"SUCCESS\",\"code\":\"0\"},
{\"tokenId\":\"aGsx\",\"deliveryStatus\":\"SUCCESS\",\"code\":\"0\"}
]}"
}
Above data is all String in single metadata column, I have split it just so that it is more readable.
But I also want to filter the data based on "deliveryStatus" contents. So when I try below query,
select * from dataTable where regexp_like(metadata,'(*)"id":"33001"(*)') AND regexp_like(metadata,'(*)\"deliveryStatus\":\"SUCCESS\"(*)');
It doesn't work. Does NOT show any result. There is no error though. I feel I need some other approach to read the nested JSON contents inside that string. But I am not sure how to do that.
Can someone provide any insights of how to achieve this?
Backslash is an escape character in regex, so you have to escape it with a second backslash.
-- sample data
with datatable as (select '{"id":"33001",
"digits":"1234",
"requestId":"5d54-f6-48-8d-8155190",
"deliveryMethod":"ATT",
"messageStatus":"{\"status\":[
{\"tokenId\":\"Zktx\",\"deliveryStatus\":\"SUCCESS\",\"code\":\"0\"},
{\"tokenId\":\"aGsx\",\"deliveryStatus\":\"SUCCESS\",\"code\":\"0\"}
]}"
}' metadata from dual)
-- actual query
select * from dataTable where regexp_like(metadata,'(*)"id":"33001"(*)')
AND regexp_like(metadata,'(*)\\"deliveryStatus\\":\\"SUCCESS\\"(*)'); -- note double backslashes
But I do recommend looking into the native JSON support if you're on Oracle 12c or up, like #thatjeffsmith mentioned. Regex work, but they're expensive and fragile.
I have a query starting with REPLACE. When I use it directly in MySQL console everything is fine, so query is ok. However, when I put it in my code like this:
#Query("REPLACE INTO WeekAggregate...
There is an error:
web - 2016-10-05 10:35:44,297 [localhost-startStop-1] ERROR o.h.hql.internal.ast.ErrorCounter - line 1:1: unexpected token: REPLACE
antlr.NoViableAltException: unexpected token: REPLACE
How could I fix this? Is REPLACE not supported in HQL?
HQL is trasversal to underlying DBMS. So some functions you're using in your SQL can't be interpretated by HQL.
You have two ways:
change your HQL query (in this case you can rewrite your query with an DELETE/INSERT statement)
you can write your query in SQL and you can use a method createSqlQuery so the interpreter, runs the query as SQL native query.
I changed my query to native SQL query by using nativeQuery = true flag.
I have an Oracle form which has EXECUTE_QUERY(NO_VALIDATE) in the KEY_EXEQUERY trigger.
I would like to see the what is the query been executed, how can I print the sql query?
In the Pre-Query trigger get the SYSTEM.LAST_QUERY value to get the text of the query.
How can the following be done with a linq statement?
SELECT Description
FROM Production.ProductDescription
WHERE FREETEXT(Description, 'Some Keywords')
No, the full text search function FREETEXT in TSQL is not directly accessible with Linq to SQL.
You would have to execute that query directly in a database function, then you can pull your result set back with Linq to SQL.
I am not sure, but you might have to search each column/property of the table against your keyword to mimick freetext.
ex:
context.Production.ProductDescription
.Where(pd=>pd.Property1.Contains("Keyword") || pd.Property2.Contains("Keyword");