i think hibernate rendered wrong SQL in DB2?
I am making a mistake certainly
my jpa code is:
public List<Gc1glcostctrmap> findByCriteria(
Map<String, SortDirectionEnum> sortFields,
Integer start,
Integer length) throws Exception {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Gc1glcostctrmap> criteriaQuery = builder.createQuery(Gc1glcostctrmap.class);
Root<Gc1glcostctrmap> root = criteriaQuery.from(Gc1glcostctrmap.class);
int noDeleted = 0;
criteriaQuery.select( root )
.where( builder.equal(root.get(Gc1glcostctrmap_.g1011logdel), noDeleted) );
if ( Validator.isNotNull(sortFields) ) {
criteriaQuery.orderBy(_orderBy(sortFields, builder, root));
}
// create query
Query query = entityManager.createQuery(criteriaQuery);
query.setFirstResult(start);
query.setMaxResults(length);
// execute query
List<Gc1glcostctrmap> gc1glcostctrmaps = query.getResultList();
return gc1glcostctrmaps;
}
and sqlshow is True, and for first page rendered:
select fields from BNGL.GC1GLCOSTCTRMAP gc1glcostc0_ where gc1glcostc0_.g1011logdel=0 order by gc1glcostc0_.g1136id asc fetch first 10 rows only
but for second page rendered:
select fields from ( select inner2_.*, rownumber() over( order by order of inner2_) as rownumber_ from
( select fields from BNGL.GC1GLCOSTCTRMAP gc1glcostc0_ where gc1glcostc0_.g1011logdel=0 order by gc1glcostc0_.g1136id asc fetch first 20 rows only ) as inner2_ ) as inner1_ where rownumber_ > 10
order by rownumber_
and Eventually error is:
2018-07-29 09:13:22.218 WARN 6684 --- [nio-8082-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: -199, SQLState: 42601
2018-07-29 09:13:22.219 ERROR 6684 --- [nio-8082-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : DB2 SQL Error: SQLCODE=-199, SQLSTATE=42601, SQLERRMC=OF;( . AT MICROSECONDS MICROSECOND SECONDS SECOND MINUTES MINUTE, DRIVER=3.68.61
2018-07-29 09:13:22.219 WARN 6684 --- [nio-8082-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: -516, SQLState: 26501
2018-07-29 09:13:22.219 ERROR 6684 --- [nio-8082-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : DB2 SQL Error: SQLCODE=-516, SQLSTATE=26501, SQLERRMC=null, DRIVER=3.68.61
2018-07-29 09:13:22.219 WARN 6684 --- [nio-8082-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: -514, SQLState: 26501
2018-07-29 09:13:22.219 ERROR 6684 --- [nio-8082-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501, SQLERRMC=SQL_CURLH200C1, DRIVER=3.68.61
2018-07-29 09:13:22.228 ERROR 6684 --- [nio-8082-exec-9] ir.bmi.service.impl.MapTstServiceImpl : Error occurred while calling findByCriteria().
You can use a custom Dialect, as the generated query in Hibernate DB2Dialect is not correct.
Please refer this answer: db2-with-pagination
Related
Does anyone know whay the following SQL code would be generating an 802 error? Could it be because the results of the count query are zero in some cases?
CEILING(CAST(round((1 / CAST(
(
SELECT COUNT(evecas)
FROM evetrn e2
WHERE e2.evesrv IN ('T005',
'T205')
AND e2.evecnf = 'K'
AND e2.evegrp = e.evegrp
AND e.evestf = e2.evestf
AND e2.evetim = e.evetim
AND lwsys.isodates(e2.evefyr, e2.evefmm, e2.evefdd)
= lwsys.isodates(e.evefyr, e.evefmm, e.evefdd)
AND evecas !=0
AND evetyp = 'S') AS float)
),4) AS float)
*1000) /1000
The full error being generated in Squirrel:
Error: [SQL0802] Data conversion or data mapping error.
SQLState: 22012
ErrorCode: -802
And this warning:
ErrorCode: 420Warning: [SQL0420] Character in CAST argument not
valid. SQLState: 01565 ErrorCode: 420
How can I fetch database which starts with number with RODBC library in R? This code gives an error:
myconn <-odbcConnect("Database")
dat <- sqlFetch(myconn, "db.8798")
Error is (after displaying dat in R console):
[1] "42000 102 [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near '.8798'."
[2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM db.8798'"
Thanks!
I am getting below error
Error at Command Line : 1 Column : 29
Error report -
SQL Error: ORA-00971: missing SET keyword
00971. 00000 - "missing SET keyword"
Please help me to solve this
here is the query that i used
update siebel.S_LOY_MEMBER a,siebel.s_contact b,siebel.s_contact_x c
SET
a.REC_PTNR_PROM_FLG ='N',
b.SUPPRESS_EMAIL_FLG ='Y',
b.SUPPRESS_FAX_FLG ='Y',
c.ATTRIB_09 ='Y'
where a.PR_CON_ID = b.par_row_id
and b.row_id = c.par_row_id
and a.PROGRAM_ID = '1-15P'
and a.REG_CHANNEL_CD ='Booking'
and a.MEM_NUM ='677609224'
Thanks
Praveen
oracle query This works
select *
from (
select to_number(substr(app_cluster,6,2), '99') as b
from xtern_app_info
WHERE app_cluster IS NOT NULL
AND APP_CLUSTER <> 'CLUSTER'
);
but when adding 'where b > 2' makes an error, why?
select *
from (
select to_number(substr(app_cluster,6,2), '99') as b
from xtern_app_info
WHERE app_cluster IS NOT NULL
AND APP_CLUSTER <> 'CLUSTER'
) where b > 2;
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-01722: invalid number
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
HANA 102.05 fails to execute the following code:
CREATE TABLE ATABLE( f INT );
CREATE PROCEDURE TestProc()
AS
BEGIN
SELECT f FROM ATABLE
FOR UPDATE; -- Without FOR UPDATE it works
END;
SELECT 'Hello' FROM DUMMY;
complaining that:
SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "SELECT": line 8 col 2 (at pos 124)
which points outside the proceudure, at SELECT 'Hello'. The procedure itself compiles without error. The entire script completes successfully if I remove the FOR UPDATE directive. What is wrong with the original?
Update
When I execute the same query from hdbsql.exe I get:
0 rows affected (overall time 26,076 msec; server time 6518 usec)
* 257: sql syntax error: line 5 col 9 (at pos 71) SQLSTATE: HY000
* 257: sql syntax error: incorrect syntax near "END": line 2 col 1 (at pos 32) SQLSTATE: HY000
'Hello'
"Hello"
1 row selected (overall time 4644 usec; server time 143 usec)