iReports ORA-00911: invalid character - jasper-reports

When I specify the query via Data-> Report Query I get the below error. It doesn't say what the invalid character is though. Any idea on how to resolve this?
Caused by: java.sql.SQLException: ORA-00911: invalid character

The problem was a semicolon (";") character in the middle of the query. The query ran in oracle SQL developer because the semicolon broke the query at a valid place.

Related

need help, bug in query select with isnull

i think this can be a bug in yii2,
when i use:
$query->select ("isnull(cba.HSLET,0)");
$query->join('INNER JOIN','cba','cba.id = regverification.cba_id');
yii miss create the sql sentence resulting in a error near:
isnull(cba.HSLET, [0)]
From Yii 2 Guide:
Besides column names, you can also select DB expressions. You must use the array format when selecting a DB expression that contains commas to avoid incorrect automatic name quoting.
So it should be:
$query->select(["ISNULL(cba.HSLET, 0)"]);

What is the best way to decipher a DB2 -302 error from Java?

I am getting this error running an insert query for a single record:
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null,
DRIVER=3.62.56
Exception: org.springframework.dao.DataIntegrityViolationException
I looked this up on IBM's help site, but there being no parameter index, I am stuck. The SQL state also seems to specify it is other than a value being too big.
The format of the query is INSERT INTO [[TABLE_NAME]] VALUES (?,?,?,...) using Spring's JdbcTemplate.update(String sql, Object... params).
This being for work, I cannot post schema nor query. I am looking for general advice into debugging this issue. I already know using Arrays.toString(Object[]) does not print out in SQL format.
To find the explanation for SQLCODE -302 in the manual you need to search for SQL0302N (the general rule for DB2 SQLCODE values is this: "SQL" plus four digits, padded if necessary with zeros on the left, plus "N" for "negative" because -302 is a negative number).
If you have the DB2 command line processor installed, you can also use it to look up error codes:
db2 ? sql302
which would produce something like this:
SQL0302N The value of a host variable in the EXECUTE or OPEN
statement
is out of range for its corresponding use.
Explanation:
The value of an input host variable was found to be out of range for
its use in the SELECT, VALUES, or prepared statement.
In other words, one of the bind variables in your INSERT is too large for the target column. You'll need to compare the table column definitions with the actual values you're trying to insert.
In addition to mustaccio's answer you can also get the info from sql with SYSPROC.SQLERRM. Example:
values SYSPROC.SQLERRM ('SQL302', '', '', 'en_US', 0)
SQL0302N The value of a host variable in the EXECUTE or OPEN statement
is out of range for its corresponding use.
Explanation:
...

DB2 LIKE operator character range

I'm attempting to construct a LIKE operator in my query on DB2 that is checking if a varchar is just two digits. I've looked online and it seems like DB2 does not support a character range i.e. [0-9]. I've tried LIKE '[0-9][0-9]' and I didn't get an error from DB2, but no rows showed up in my result set from that query when I can see rows that exactly match this through looking at a SELECT * of the same table.
Is there anyway I can replicate this in DB2 if it is indeed true? Is my syntax for the LIKE wrong? Thanks in advance.
The TRANSLATE function is more appropriate for validating an expression that contains a limited number of valid values.
WHERE TRANSLATE( yourExpressionOrColumn, '000000000', '123456789') = '00'
Found it. No you cannot and there are no symbols that can represent an OR in LIKE.

SQL LIKE statement using using unicode characters does not show correct result

I'm using SQL Server 2008 R2. I'm just wondering why this statement doesn't work correctly.
For example: The statement
WHERE CONTRACTORNAME LIKE '%á%'
would gives me the correct result for every records containing "á". But the statement
WHERE CONTRACTORNAME LIKE '%ạ%'
would not gives any records even though in CONTRACTORNAME column have a tons of records containing this character. Any help?
Try using a Unicode search string:
WHERE CONTRACTORNAME LIKE N'%ạ%'

SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null

What does sqlcode -302 means?
Where do i get the sqlcode definitions?
Please advice
Thanks,
You can find the codes in the DB2 Information Center. Here's a definition of the -302 from the z/OS Information Center:
THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS
INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE
On Linux/Unix/Windows DB2, you'll look under SQL Messages to find your error message. If the code is positive, you'll look for SQLxxxxW, if it's negative, you'll look for SQLxxxxN, where xxxx is the code you're looking up.
To get the definition of the SQL codes, the easiest way is to use db2 cli!
at the unix or dos command prompt, just type
db2 "? SQL302"
this will give you the required explanation of the particular SQL code that you normally see in the java exception or your db2 sql output :)
hope this helped.
As a general point when using a search engine to search for SQL codes make sure you put the sqlcode e.g. -302 in quote marks - like "-302" otherwise the search engine will exclude all search results including the text 302, since the - sign is used to exclude results.