Use of function TIMESTAMP_FORMAT in QSYS2 not valid. Data mapping error on member - db2-400

I am very new in iseries/DB2.
We use V7R3. We have table that is generated every day by RPG program as physical file. For accessing the table data from java we use jt400.jar jdbc driver.
Most of the table queries work fine but some complex queries that are using "DENSE_RANK() OVER(ORDER BY" and "ROW_NUMBER() OVER(PARTITION BY" time to time hanging and causing CPU 100%. only killing the job on AS400 side is resolving the issue.
in the AS400 log I see:
Job 969954/QUSER/QZDASOINIT started on 02/21/19 at 09:36:46 in subsystem
QUSRWRK in QSYS. Job entered system on 02/21/19 at 09:36:46.
User USERXX from client X.X.X.X connected to server.
Use of function TIMESTAMP_FORMAT in QSYS2 not valid.
Use of function TIMESTAMP_FORMAT in QSYS2 not valid.
Data mapping error on member TABLE_NAME.
Data mapping error on member TABLE_NAME.
Data mapping error on member TABLE_NAME.
Data mapping error on member TABLE_NAME.
Value in date, time, or timestamp string not valid.
It looks similar as problem described in the Why am I getting a "[SQL0802] Data conversion of data mapping error" exception?
and probably the problem is related to invalid data stored to DATE type columns.
Looking to the DATE columns I see that some records displayed as <null> in SQuirrel SQL Client. Interesting that here are 2 different <null>'s returned by distinct query.
If I run
select distinct VARCHAR_FORMAT(DATE_COLUMN, 'YYYY/MM/DD') from TABLE_NAME
I get
0001/01/01
and
9999/12/31
for these <null>'s rows.
if I run Select * from TABLE where DATE_COLUMN is null I don't get any results. So I am not sure what kind of <null>'s is that.
Not sure if these records can cause an issue.
UPD: when I run
Select * from TABLE
I see errors in JDBC client log:
Warning: [SQL0181] Value in date, time, or timestamp string not valid.
SQLState: 01534
ErrorCode: 181
Warning: [SQL0181] Value in date, time, or timestamp string not valid.
SQLState: 01534
ErrorCode: 181Warning: [SQL0181] Value in date, time, or timestamp string not valid.
SQLState: 01534
ErrorCode: 181
Warning: [SQL0181] Value in date, time, or timestamp string not valid.
SQLState: 01534
ErrorCode: 181
Query 1 of 1, Rows read: 100, Elapsed time (seconds) - Total: 0.252, SQL query: 0.005, Reading results: 0.247
based on https://www.consolut.com/en/s/sap-ides-access/d/s/p/40/doc/XH-SQL0181/ it should be incorrect date somewhere in the table
The question is there any way to find and filter records that have "invalid" data (causing above exception in the log) from SQL side?

Related

JMeter: Inserting record into database by using JDBC request

I have configured JDBC connection in my JMeter test plan.
The database settings in JDBC connection are configured correctly.
I am extracting employee id from one of my requests response.(i.e Employee_Id)
By using BSF PostProcessor, i have stored the employee id into a variable called as Emp_ID
I want to insert the extracted employee id into my database.
Database used is Oracle SQL developer, Version 4.0.1.14,Build MAIN-14.48.
Table name is : Employee_Details
Column name is : Employee_id ,Datatype: VARCHAR2
In JDBC request,i have selected "Query Type" as "Update Statement" and entered the following query:
Query 1: INSERT INTO Employee_Details (Employee_id)
VALUES (${Emp_ID})
Query 2: INSERT Employee_id='${Emp_ID}'
Parameter Types is given as VARCHAR2.
On both the execution, JMeter displays error as "Cannot create PoolableConnectionFactory (ORA-00923: FROM keyword not found where expected)"
Please provide your valuable suggestion on this.
I found a workaround for this that avoids having problems:
JDBC Request Query Type needs to be: Update Statement
The query needs to be processed as a block
BEGIN
SQL Statement
END;
My expectation is that you have incorrect validation query:
If you left the "Validation Query" box value default - Select 1 - Oracle may not like it very much. You need to change it to select 1 from dual
References:
DBCP - validationQuery for different Databases
The Real Secret to Building a Database Test Plan With JMeter
ORA-00923: FROM keyword not found where expected tips
There are 3 things as follows:
Check the validation query and keep it blank. Screenshot is attached
When you are executing insert query, keep Query Type as Updated
When you are executing query please add database.tablename and then execute.

How to solve : SQL Error: ORA-00604: error occurred at recursive SQL level 1

When I'm trying to drop table then I'm getting error
SQL Error: ORA-00604: error occurred at recursive SQL level 2
ORA-01422: exact fetch returns more than requested number of rows
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
One possible explanation is a database trigger that fires for each DROP TABLE statement. To find the trigger, query the _TRIGGERS dictionary views:
select * from all_triggers
where trigger_type in ('AFTER EVENT', 'BEFORE EVENT')
disable any suspicious trigger with
alter trigger <trigger_name> disable;
and try re-running your DROP TABLE statement
I noticed following line from error.
exact fetch returns more than requested number of rows
That means Oracle was expecting one row but It was getting multiple rows. And, only dual table has that characteristic, which returns only one row.
Later I recall, I have done few changes in dual table and when I executed dual table. Then found multiple rows.
So, I truncated dual table and inserted only row which X value. And, everything working fine.
I know the post is old and solved, but maybe someone is facing or will face my situation, so I want to leave the aquired knowledge here, after deal with the error for a week. I was facing the error: "ORA-00604: error occurred at recursive SQL level 1" , but with the internal error: " ORA-06502: error: character string buffer too smal numeric or value", this happened only when I try to logon the database, and using an specific driver, trying to connect from an Visual Studio C# application, the weirdest thing on that moment was that I connect from SQLDeveloper or TOAD and everything worked fine.
Later I discovered that my machine name had this format "guillermo-aX474b5", then I proceed to rename it like this "guillermo" without the "-" and the other stuff, and it worked!! Looks like in some drivers and situations, ORACLE Database does'nt like the "-" in the LogOn connection.
Hope it helps!

JDBC Error in insert with DB2 (works with Sql Server)

I use in a Java Application JDBC to query the DBMS. The application works correctly with Sql Server but I get this error in DB2 during one insert:
com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=1, DRIVER=3.63.75
The insert is made using the ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE.
My query is a plain select of the table, then I declare my PreparedStatement, passing the parameters and afterwards with the ResultSet I do first the moveToInsertRow() and then the insertRow().
Do you know if there are any problems with this approach using DB2?
As I told you before the same code works correctly with Sql Server.
SQL Code -302 on DB2 means:
THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE
So it seems like you are trying to insert a value into a column which is too large or too short (e.g. Hello World into a varchar(5)). Probably the column has a different length in DB2 and sql-server or you are inserting different values.
Probably too late to add to this thread.. but someone else might find it useful
Got the same SQL Exception when trying to do a SELECT : didn't realize the property value in WHERE clause was exceeding the limit on the corresponding column
SELECT * FROM <schema>.<table_name> WHERE PropertyName = 'value';
value was a VARCHAR type but exceeded the Length limit
Detailed exception does say it clearly that data integrity was violated: org.springframework.dao.DataIntegrityViolationException
So a good idea would be to do a length check on the value(s) that are being set on the properties before firing any queries to the database.

weird exception in Hive : Error in semantic analysis

Maybe when you see the "Error in semantic" in the title, you consider it as syntax error?
Of course not, I will show you what happened.
hive> use android;
OK
Time taken: 0.223 seconds
hive> desc tb_user_basics;
OK
col_datetime string
col_is_day_new string
col_is_hour_new string
col_ch string
...
p_date string
p_hourmin string
Time taken: 0.189 seconds
hive> select count(distinct col_udid) from android.tb_user_basics where p_date>='20121001' and p_date<='20121231';
FAILED: Error in semantic analysis: org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
hive>
>
> select count(distinct col_udid) from android.tb_user_basics where p_date>='20121001' and p_date<='20121231';
FAILED: Error in semantic analysis: Unable to fetch table tb_user_basics
I'm very sure the table does exist in the database android. After the first statement failed, it appears that the table is missing.(Even I add the db prefix in the table name)
I'm wonderring whether it's because of the volumn of data is very big, maybe you have noticed that the time range is [20121001, 20121231].
I run the command before many times, always raise this error. But if I change the contition to "p_date='20121001'", the statement can run normally. (since the volumn is smaller? )
I'm expecting your answers, Thanks.
Probably you are in strict mode. One of strict mode feature is that partitions has to be specified, so this is why queries with "p_date='20121001'" in where cause are working.
Please try the non-strict mode:
set hive.mapred.mode=nonstrict;

Comparing Date column to sysdate yields: a non-numeric character was found where a numeric was expected

I've been having a strange issue where the comparison of a date column to SYSDATE yields the following error:
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
I'm re-creating a MATERIALIZED VIEW; which included some minor changes, and whenever the process aborts it always points to the '>=' in the following derived table query:
SELECT id,
desc,
start_date,
end_date
FROM T_LIPR_POLICY_ROLE TLPR
WHERE end_date >= SYSDATE
Now end_date is a type DATE, and I can actually execute this query by itself, but whenever I try to run it in the materialized view it always aborts with the error above. Although last week I was able to create it with the same query.
Any ideas?
Thank you,
Hi I'm terribly sorry for the long delay. I just couldn't post the whole statement for security reasons.
Now the issue has been resolved. The problem was that our materialized view script was aggregating data from 17 different places vía a UNIONs. Now for some reason the error was pointing to wrong line of code (see below).
SELECT id,
desc,
start_date,
end_date
FROM T_LIPR_POLICY_ROLE TLPR
WHERE end_date >= SYSDATE <-- ORACLE POINTS TO THIS LINE
Now this was like the tenth statement in the script, but the error really was in the sixth statement in the script; which was obviously misleading. In this statement a particular record (out of millions) was attempting the following operation:
to_date(' / 0/ ') <-- This was the cause of the problem.
Note that this text wasn't like this in the actual script it literally said to_date(<column name of type varchar>), but 2 records out of 15 million had the text specified above.
Now what I don't quite get is why Oracle points to the wrong line of code.
¿Is it an Oracle issue?
¿Is it a problem with the SQL Developer?
¿Could it be a conflict with a hint? We use several like this: /*+ PARALLEL (init 4) */
Thank you for all your help.
Is desc a column name? If yes then you are using a oracle reserved keyword desc as a column name.
SELECT id,
desc,---- here
start_date,
end_date
FROM T_LIPR_POLICY_ROLE TLPR
WHERE end_date >= SYSDATE
We cannot use oracle reserved keywords in column names.
Please change the column name.

Resources