Jaspersoft Ireport doesn't support UTF-8 queries (Hebrew language) - utf-8

in Ireport 4.8.0
i need to write query with a "where" phrase that include a "UTF-8" word, like this:
SELECT
accounts.name AS accounts_name,
accounts.billing_address_city AS accounts_billing_address_city
FROM
accounts accounts
WHERE
accounts.name = "מיינפורם"
when i write it in Ireport, it doesn't find anything because it doesn't recognize the UTF-8 word in the where clause:
when the same exact query does work in the MySQL database:
So the problem is in the Ireport that deosn't recognize the UTF-8 word,
how can i fix this?

Solved it by defining a new database connection and this time with the following parameters:
jdbc:postgresql://IPAddress/DatabaseName?useUnicode=true&characterEncoding=UTF-8
From this point on, the report query started to return results.

Related

How to TRIM OR TRUNCATE first character in DB2 column

I have column phone number with value and want to update the table column such that country code doesnt exist.
19083452345
14084456789
12023458900
18163456789
I tried to use LPAD, LTRIM but couldnt succeed.
Something like this using SUBSTR:
update tablename set phone=substr(phone,2,length(phone)-1)
Use regular expressions (regex). Before doing it, check for the way country code are being written in your database, what standard is being used, if any (E.164 is tendency, but not always followed). For example, a mobile phone number in UK may be registered as '07911 123456' or also '+44 7911 123456' (and with or without blanks). There is a great deal of regular expressions in pages such as http://regexlib.com/Search.aspx?k=phone+number&c=0&m=0&ps=20&p=11&AspxAutoDetectCookieSupport=1
I don't know what flavor of Db2 are you using (Db2 for IBM i, Db2 for zOS, or Db2 for LUW) and it may have small variations on the regex support among them. The following article explain how to use regex in Db2 11.1 for LUW: https://www.idug.org/p/bl/et/blogaid=605

Is there a Hadoop/Hive setting that influences how column headers are returned?

semi-SQL literate QA guy here!
We're adding Hadoop/Hive integration into our product for a client. I've been given a build to test, and I'm running into a problem - the SQL statements I'm using are returning Hive table column headers in lowercase.
For example:
If my SQL is: "select FIRST_NAME from recipient_data;"
My query is returning: "first_name"
My product is case-sensitive, and the engineer helping me troubleshoot this issue says it seems to be a function of our Hadoop driver, and not anything our program is doing with the returned values. Is there a way to configure Hadoop/Hive to not lowercase the column headers it returns?

MS Access Expressions in Pass-Through Query to Oracle DB

I am trying to create a Pass-through SQL statement from my MS Access 2003 (Yeah, I know it's oldschool but my hands are tied :/) to an Oracle DB on a Server.
Long story short, the server-table contains freezer models, where each model exists 1 to 5 times with the ID prefixed with a value indicating it's condition. The problem is, that I have to fetch all "versions" of a freezer. In Access I would write something like:
SQL = "SELECT Right(FREEZERS.ID,4) FROM FREEZERS WHERE Right(FREEZERS.ID,4) = '" & myID & "'"
But this triggers an error in my Pass-through query to Oracle. Is it even possible to write expressions like this in a pass-through query?
I am using vba and a QueryDef with a connectstring to the server (which works fine if i strip the Right()-expression), and then open a recordset with the result.
Thanks on beforehand, Viggo
EDIT:
Ah, sorry..
Took one last Googling and the Answer popped up:
Apparently Oracle has a different syntax for some of these functions. In this case I found that Oracle has a SUBSTR-function and a LENGTH-function, fixing my problem..
To others in search: The key is searching for Oracle syntax rather than Pass-through syntax..
Source:
http://peoplesofttipster.com/2008/08/18/substringing-and-oracle-sql-basic-trick/
Hope it can help someone else :)
As described in the above:
In Pass-Through queries the SQL language of the server.. :)

How to make Oracle 'order by' behave like SQLServer?

i'm trying to write an Oracle query that sorts the results in the same way as MS SQL Server does. I'm toying with the 'NLSSORT' function and it's parameters but i can't get exactly the same results as what i can see with MS SQL Server.
The context is a generic data collection system that supports both Oracle and MS SQL Server. This is a pretty old system that is still under maintenance and development. No entity framework or any recent approaches to handle database interactions.
With a simple order by on MS SQL Server i get this result:
_TEST
04-00031-IPE
04-00044-OG
0A-A
A0-A
SAZ2217
The same query on Oracle returns this:
04-00031-IPE
04-00044-OG
0A-A
A0-A
SAZ2217
_TEST
I have tried many combinations of NLSSORT parameters without any success.
[edit]
By using the 'PUNCTUATION' NLS_SORT parameter value, i get results very close to the MS SQL sorting but there is still differences with substrings that contains sequences of numeric chars. Here is a sample query result:
Oracle
0031-CASTOR-BLOC1-AV-AP
0031-CASTOR-BLOC1-AV-SP
0031-CASTOR-BLOC1-SV-AP
0031-CASTOR-BLOC1-SV-SP
0031-CASTOR-BLOC10-DV-AP
0031-CASTOR-BLOC10-DV-SP
0031-CASTOR-BLOC2-DV-AP
Ms SQL
0031-CASTOR-BLOC10-DV-AP
0031-CASTOR-BLOC10-DV-SP
0031-CASTOR-BLOC1-AV-AP
0031-CASTOR-BLOC1-AV-SP
0031-CASTOR-BLOC1-SV-AP
0031-CASTOR-BLOC1-SV-SP
0031-CASTOR-BLOC2-DV-AP
Thank you for your help!
I finally found this solution:
ORDER BY NLSSORT(COLUMN_NAME, 'NLS_SORT = FRENCH_M')
At least in my particular context, i get the same sorting under both MS SQL Server (default sorting) and Oracle.
Here is two useful links:
http://www.myoracleguide.com/xl/Linguistic_Sorting_Frequently_Asked_Questions.htm
http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch5lingsort.htm#NLSPG005
Could consider use of rpad function?
e.g.
select name, rpad(upper(replace(translate(name,'_','+'),'-','') ),15,'0') as v1
from sorttest order by
rpad(upper(replace(translate(name,'_','+'),'-','') ),15,'0')

Linq equivalent of SQL LEFT function?

We have a database with some fields that are varchar(max) which could contain lots of text however I have a situation where I only want to select the first for example 300 characters from the field for a paginated table of results on a MVC web site for a "preview" of the field.
for a simplified example query where I want to get all locations to display in the table
(this would be paginated, so I don't just get everything - I get maybe 10 results at a time):
return db.locations;
However this gives me a location object with all the fields containing the massive amounts of text which is very time consuming to execute.
So what I resorted to before was using SQL stored procedures with the:
LEFT(field, 300)
to resolve this issue and then in the Linq to SQL .dbml file included the stored procedure to return a "location" object for the result.
However I have many queries and I don't want to have to do this for every query.
This maybe a simple solution, but I am not sure how I can phrase this on a search engine, I would appreciate anyone who can help me with this problem.
You can use functions that directly translate to those functions too, this is useful when you need to translate code that functionally works just fine in SQL at no risk in LINQ.
Have a look at System.Data.Objects.EntityFunctions
Locations.Select(loc=>System.Data.Objects.EntityFunctions.Left(loc.Field,300))
This will get directly translated into a LEFT on the server side.
EDIT: I misread LEFT for LTRIM. Here's all the String functions that can't be used in LINQ to SQL. Have you tried String.Substring()?
Your best option is to map the stored procedure and continue using it. Here is an excellent article with screen shots showing you how to do so.
If you're not using the designer tool you can also call ExecuteCommand against the DataContext. It isn't pretty, but it's what we have for now.
I found something like this worked for me:
return from locationPart in db.locations
select new LocationPart
{
Description = locationPart.description,
Text = locationPart.text.Substring(0,300)
};
Not ideal because I have to use "select new" to return a a different object, but it seems to work.

Resources