Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

OpenSQL exception with where xxx like 'xxx%'

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) {
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: 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,


Former Member
Not what you were looking for? View more on this topic or Ask a question