Skip to Content
avatar image
Former Member

SQLJ interator

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jul 27, 2004 at 08:09 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 27, 2004 at 01:38 PM

    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??

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 28, 2004 at 05:01 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded