cancel
Showing results for 
Search instead for 
Did you mean: 

SQLJ interator

Former Member
0 Kudos

Hi

I am try to implement the Java Persistence tutorial sample, but It's not working.

In the following code:

================================

EmployeeIter iter = null;

#sql [ctx] iter = {

select EMPID, FIRST_NAME, LAST_NAME, SALARY

from TMP_EMPLOYEE

};

================================

I got error messages in #sql line:

- SQLJ: Left hand side of assignment does not have a Java type.

- SQLJ: Return type incompatible with SELECT statement: com.sap.sql.sqlj.semantics.TypeProperties$Invalid is not an iterator type

Following the code of iterator:

================================

package tutoper.dao;

#sql iterator EmployeeIter(int EMPID, String FIRST_NAME, String LAST_NAME, java.math.BigDecimal SALARY);

================================

Any suggestion?

TIA

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I moved the interator class to the DAO and the problem was solved...

That's quite interesting because if the class was not resolved, why there was no error in the line:

EmployeeIter iter = null;

It seems that the erros during processing of SQLJ make eclipse confuse (and me too and drops messages??

The best approach seems to put SQLJ in comments, and check the rest of the code for erros.

Former Member
0 Kudos

I did some tests and I found that when I change the name of the variable 'iter' (for example: 'iterx') the error messages stay the same. So I suppose this is the point of error...But what is wrong?? It seems that SQLJ is not recognizing the variable name??

Former Member
0 Kudos

Hi,

looks fine to me.

I would rebuild the whole project, that helps sometimes with stranges errors in sqlj.

And if your iterator and the select-class are not in the same package you might need to import the iterator class.

Regards, Astrid