jdbctemplate不从存储过程返回数据

afdcj2ne  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(262)

我想打电话给我的朋友 Teradata 使用simplejdbccall的存储过程,但是我总是得到零结果,尽管我的表中有可用的数据。我试着调试,但没有成功。这是我的存储过程。我做错什么了吗?

REPLACE PROCEDURE MYPROC
    (
        IN ID VARCHAR(50)

    )
    DYNAMIC RESULT SETS 1
    MAIN : BEGIN
        DECLARE ltype VARCHAR(256);

        DECLARE mainSql  VARCHAR (5000);
        DECLARE emptySql VARCHAR(5000);
        DECLARE mainCur CURSOR WITH RETURN ONLY FOR mainStmt;
        DECLARE emptyCur CURSOR WITH RETURN ONLY FOR emptyStmt;

        SET mainSql =   'LOCKING ROW FOR ACCESS SELECT * FROM MYTABLE where ID = ''' || ID || ''';'; 

        SET emptySQL = 'SELECT NULL AS ID;';

        PREPARE mainStmt FROM mainSql;
        PREPARE emptyStmt FROM emptySql;    

        BEGIN TRANSACTION;

            SET statementNo = 100;
              OPEN mainCur;

        END TRANSACTION;
    END MAIN;

这是我的SimpleJDBCall

simpleJdbcCall.withProcedureName("MYPROC").returningResultSet("mainCur",
                BeanPropertyRowMapper.newInstance(MYCLASS.class) ).declareParameters(new SqlParameter(ID, Types.VARCHAR) );
        SqlParameterSource namedParameters = new MapSqlParameterSource("ID", transId);

        try {
            Map<String, Object> out = simpleJdbcCall.execute(namedParameters);
            System.out.println(out);
        } catch (Exception e) {
            System.err.println(e);
        }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题