1

Oracle stored procedure:

create or replace PROCEDURE "TGT_MPD_PLANOGRAM_SEL_SP" (
    POG_NUM_IN IN VARCHAR2,
    PLAN_DATA_SEL_CUR OUT SYS_REFCURSOR,
    SQL_CODE_OUT OUT NUMBER,
    SQL_ERR_MSG_OUT OUT VARCHAR2)
AS
...

Mapper.xml

<select id="getPlanograms" statementType="CALLABLE"
        parameterType="com.tgt.snp.pog.vo.PlanogramSearchVO"
        resultMap="mapResultPlanogram">
    {
        CALL TGT_MPD_PLANOGRAM_SEL_SP(
            #{POG_NUM_IN,javaType=String,jdbcType=VARCHAR,jdbcTypeName=VARCHAR2,mode=IN},
            #{PLAN_DATA_SEL_CUR,jdbcType=CURSOR,resultMap=mapResultPlanogram,mode=OUT},
            #{SQL_CODE_OUT,javaType=Integer,jdbcType=INTEGER,jdbcTypeName=INTEGER,mode=OUT},
            #{SQL_ERR_MSG_OUT,javaType=String,jdbcType=VARCHAR,jdbcTypeName=VARCHAR2,mode=OUT}
        )
    }
</select>

VO Object

public class PlanogramSearchVO {

    public PlanogramSearchVO(){}
public String getPOG_NUM_IN() {
        return POG_NUM_IN;
    }

    public void setPOG_NUM_IN(String POG_NUM_IN) {
        this.POG_NUM_IN = POG_NUM_IN;
    }

    private String POG_NUM_IN;

    public ResultSet getPLAN_DATA_SEL_CUR() {
        return PLAN_DATA_SEL_CUR;
    }

    public void setPLAN_DATA_SEL_CUR(ResultSet PLAN_DATA_SEL_CUR) {
        this.PLAN_DATA_SEL_CUR = PLAN_DATA_SEL_CUR;
    }

    private ResultSet PLAN_DATA_SEL_CUR;

    public Integer getSQL_CODE_OUT() {
        return SQL_CODE_OUT;
    }

    public void setSQL_CODE_OUT(Integer SQL_CODE_OUT) {
        this.SQL_CODE_OUT = SQL_CODE_OUT;
    }

    private Integer SQL_CODE_OUT;

    public String getSQL_ERR_MSG_OUT() {
        return SQL_ERR_MSG_OUT;
    }

    public void setSQL_ERR_MSG_OUT(String SQL_ERR_MSG_OUT) {
        this.SQL_ERR_MSG_OUT = SQL_ERR_MSG_OUT;
    }

    private String SQL_ERR_MSG_OUT;
}

Error Message

Caused by: org.springframework.jdbc.UncategorizedSQLException: 
### Error querying database.  Cause: java.sql.SQLException: Non supported SQL92 token at position: 1: 
### The error may exist in class path resource [PlanogramMapper.xml]
### The error may involve com.tgt.snp.pog.mapper.PlanogramMapper.getPlanograms-Inline
### The error occurred while setting parameters
### SQL: {           ?,           ?,           ?            = CALL TGT_MPD_PLANOGRAM_SEL_SP(             ?                        )         }
### Cause: java.sql.SQLException: Non supported SQL92 token at position: 1: 
; uncategorized SQLException for SQL []; SQL state [99999]; error code [17034]; Non supported SQL92 token at position: 1: ; nested exception is java.sql.SQLException: Non supported SQL92 token at position: 1: 

Please help point out what did I wrong? Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
VietRoadie
  • 179
  • 3
  • 11

1 Answers1

1

The <select> element does not need a resultMap attribute because it is not used here: calling a procedure with out parameters, even if they are cursor/resultSet, is not a SELECT.

You may need to specify the java type as result set in the parameter definition:

#{PLAN_DATA_SEL_CUR, jdbcType=CURSOR, javaType=java.sql.ResultSet, resultMap=mapResultPlanogram, mode=OUT}

The property PLAN_DATA_SEL_CUR in class PlanogramSearchVO must not be java.sql.ResultSet but rather something like List<Planogram> if the the result map mapResultPlanogram maps cursor results to a Planogram object.

Mybatis is doing the work of fetching/mapping the resultSet/Cursor to a list of objects; with the drawback that the control is returned only when the cursor is fully fetched: no custom result handling, lazy/differed loading, ... I have answered another question about this.

Community
  • 1
  • 1
blackwizard
  • 2,034
  • 1
  • 9
  • 21