Accented characters in Query Oracle SQL - oracle

i would like to display the result this query :
select t_req from table where t_req='TÉLITINO MORINOS' but i return 0 lines but i have this lines in table contains the t_req='TÉLITINO MORINOS'.
How can i Get the résult in PL/SQL Oracle?
Thanks in advance

Related

Nifi throwing None of the fields in the record map to the columns defined by [table name]

Am trying execute a sql query on oracle database and inserting the result into another table, for my trial am just performing a simple query as
SELECT 1 AS count
FROM dual
and trying to insert that into a single column table which has the name COUNT.
The content of the record on Nifi seems to be as follows
[
{
"COUNT" : "1"
}
]
but the logs keeps throwing the error
due to java.sql.SQLDataException:
None of the fields in the record map to the columns defined by
the schema_name.table_name table:
any ideas ?
I believe you get that same error message if your table name doesn't match. The Translate Field Names property only translates the fields (columns), not the table name. Try specifying the schema/table in uppercase to match what Oracle is expecting.

how to selects rows based on a single value against a comma separated column in oracle?

I have a table structure like below:
TestTable:
ID(number)|Names(clob)
1 'a','b','c','d'
2 'b','c','d'
3 'g','h','e'
Now I want to select rows in which Names column contains 'b',so the expected output will be the first 2 columns.
How can do it in Oracle.
Please remember, the solution has to work in Oracle 10g as well as 11g.
Thanks in advance.
Try this using LIKE operator:
select
*
from your_table
where ',' || Names || ',' like '%,b,%';
Concatenated commas are to cover for the cases where b is present at the start or end of the string.

How to create a blank/empty column with SELECT query in oracle?

I want to generate an output with blank/empty column with a "Select" query in oracle. I'm able to achieve this with below sql query:
SELECT CustomerName AS Customer, "" AS Contact
FROM Customers;
So when I run above sql query it returns a table with two columns "Customer" column with content in it and "Contact" column with no content or blank column.
I want to achieve same with oracle query. Any help will be highly appreciated.
I think you should use null
SELECT CustomerName AS Customer, null AS Contact
FROM Customers;
And Remember that Oracle
treats a character value with a length of zero as null.
In DB2, using single quotes instead of your double quotes will work. So that could translate the same in Oracle..
SELECT CustomerName AS Customer, '' AS Contact
FROM Customers;
I guess you will get ORA-01741: illegal zero-length identifier if you use the following
SELECT "" AS Contact FROM Customers;
And if you use the following 2 statements, you will be getting the same null value populated in the column.
SELECT '' AS Contact FROM Customers; OR SELECT null AS Contact FROM Customers;

Oracle Convert table rows to list

I have a table A with single column
**TableA**
Row1
Row2
Row3
.....
I have to convert the table rows into a list and store them in variables. So that they are stored as
Row1,Row2,Row3,....,Rown
I used the listagg () function to achieve the solution.
DECLARE
tbl_list CLOB;
BEGIN
SELECT listagg (''''||Column_name||'''',',') WITHIN GROUP (ORDER BY Column_name) INTO TBL_LIST FROM TableA;
END;
This works fine if the TableA has few rows. But if the table has lots of rows I get the following error
ORA-01489: result of string concatenation is too long
Is this due to the storage limit of variable TBL_LIST? Can anyone explain me what is wrong. And is there an alternate for lisagg(), to achieve the result, I want?
listagg function is limited to 4000 characters, if it exceeds 4000 character yo may get an error ORA-01489: result of string concatenation is too long
You can use XMLAGG which is not limited to 4000 char.
SELECT
RTRIM(XMLAGG(XMLELEMENT(E,''''||Column_name||'''',',').EXTRACT('//text()')
ORDER BY Column_name).GetClobVal(),',')
from TableA;
you can refer this question: How to tweak LISTAGG to support more than 4000 character in select query?
If you expect the result of aggregation to be more than 4000 bytes? If so, you could potentially create a user-defined aggregate function that returns a CLOB rather than a VARCHAR2. If you don't expect the result to exceed 4000 bytes there is probably something wrong with the way you've specified the aggregate.
Please refer to the "https://oracle-base.com/articles/misc/string-aggregation-techniques" for user defined aggregation.

How to show star at first two character of a string in oracle query?

Example if an ID is 1213 i want show **13.
If it's a number
select '**' || substr(to_char(id),3)
from my_table
Or, if it's already a character
select '**' || substr(id,3)
from my_table
This concatenates ** onto the beginning of the string, using the Oracle concatenation operator || and removes the first two characters of the id using substr.
Here's a SQL Fiddle to demonstrate.
If you don't want to sacrifice performance too much, to mask first two characters you can use-
SQL> select regexp_replace('1213','(.)2','**') from dual; --if VARCHAR
MASKED
------------
**13
SQL> select regexp_replace(1213,'(.)2','**') from dual; --if NUMBER
MASKED
------------
**13
REGEXP_REPLACE will work alike on NUMBER and VARCHAR so you save some conversion time there.
Consecutively, you can create a Function Based Index on the regexp function operation to optimize the query like (considering you would always want to mask only first two characters of ID) -
CREATE INDEX
mask_id
ON
table_name
(regexp_replace(id,'(.)2','**'));

Resources