cancel
Showing results for 
Search instead for 
Did you mean: 

OpenSQL exception with where xxx like 'xxx%'

Former Member
0 Kudos

Hello all,

i would write an Application for detailed Portal Activity Reporting. I build this method to connect the database

public ResultSet getResultSet(String sqlStatement) throws SQLException {		
DataSource dataSource= null;
ResultSet resultSet= null;
try {
InitialContext initialContext= new InitialContext();
dataSource= (DataSource) initialContext.lookup("jdbc/SAP/EP_PCD");
java.sql.Connection connection= dataSource.getConnection();
java.sql.Statement statement= connection.createStatement();
resultSet= statement.executeQuery(sqlStatement);
return resultSet;
} catch (NamingException e) {
e.printStackTrace();
}
return resultSet;
}

When i try to execute an SQL Statement with "where xxx like 'xxx%'" i get an exception.

In Details:

When i execute this statement it works as is should:

select * from WCR_USERSTAT where LOGONID like 'prefix%'

LogonId has the DB type nvarchar(255).

But this Statement gives me an Exception:

select * from WCR_WEBCONTENTSTAT where PCDURL like 'test%'

PCDURL has the type nvarchar(1024). The Exception says:

com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM "WCR_WEBCONTENTSTAT" WHERE "PCDURL" LIKE 'test%'" contains the semantics error[s]: type check error: the expression >>"PCDURL"<< (LONGVARCHAR) is not comparable and must not be used with "LIKE"

Why can i use "like" in the first statement but not in the second? I see only the difference in the length of the field. Is there any restriction from SAP for nvarchar fields and like statements?

Any help is welcome.

Best regards,

Patrick

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member445109
Active Participant
0 Kudos

Hi All

I am also facing the same problem "longvarchar is not comparable and must not be used with "=" .

Did you get the result, if any one knows the solutions please reply it.

BR

Sri

Former Member
0 Kudos

Hi Patrick,

I also had the same problem while accessing the Portal base on MSSQL.

My issue is with (LONGVARCHAR) ,while customizing the Portal activitiy reporting using the WCR_WEBCONTNETSTAT and WCR_USERSTAT table. Following is the exception:

he SQL statement "SELECT "WCR_USERSTAT"."USERTYPE","WCR_USERSTAT"."LOGONID","WCR_WEBCONTENTSTAT"."PCDURL","WCR_WEBCONTENTSTAT"."TIMESTAMPHOUR","WCR_WEBCONTENTSTAT"."AGGREGATIONLEVEL","WCR_WEBCONTENTSTAT"."COUNTER","WCR_WEBCONTENTSTAT"."OBJECTTYPE","WCR_WEBCONTENTSTAT"."IMPRESSIONS","WCR_WEBCONTENTSTAT"."VISITS","WCR_WEBCONTENTSTAT"."CUSTOM","WCR_WEBCONTENTSTAT"."ID" FROM "WCR_WEBCONTENTSTAT" INNER JOIN "WCR_USERSTAT" ON "WCR_USERSTAT"."TIMESTAMPHOUR" = "WCR_WEBCONTENTSTAT"."TIMESTAMPHOUR" AND "WCR_WEBCONTENTSTAT"."AGGREGATIONLEVEL" = 'd' AND "WCR_USERSTAT"."AGGREGATIONLEVEL" = 'd' ORDER BY 4,3" contains the semantics error[s]: - 1:542 - type check error: the column >>PCDURL<< (LONGVARCHAR) may not appear in the ORDER BY list because the JDBC type LONGVARCHAR is not comparable at com.sap.sql.jdbc.common.StatementAnalyzerImpl.check(StatementAnalyzerImpl.java:38) at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:101) at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:87) at com.sap.sql.jdbc.common.CommonStatementImpl.executeQuery(CommonStatementImpl.java:114) at com.sap.engine.services.dbpool.wrappers.StatementWrapper.executeQuery(StatementWrapper.java:172) at cmc.WebStats.getDataJoin(WebStats.java:343) at cmc.WebStats.wdDoInit(WebStats.java:124) at cmc.wdp.InternalWebStats.wdDoInit(InternalWebStats.java:161) at

Hope you got the solution for the LONGVARCHAR problem.

Could you pls post the solution or refer any forum links or articles regarding these.

Thanks,

Srini

Former Member
0 Kudos

Hi Patrick,

Did you solve this problem?. i am having the same problem . please let me know if you have solved the problem.

krish.

Former Member
0 Kudos

The problem might be with data type PCDURL

Regards

Sai