简体   繁体   English

MyBatis Oracle呼叫PLS-00306:呼叫错误的参数数量或类型错误

[英]MyBatis Oracle Call PLS-00306: wrong number or types of arguments in call Error

I'm trying to call to a PL/SQL stored procedure from MyBatis. 我正在尝试从MyBatis调用PL / SQL存储过程。

I'd try several options and configurations for the Select Callable statement type, but I'm block on this error. 我会为“选择可调用”语句类型尝试几种选项和配置,但是我对此错误有所保留。

I have this configurations / files: 我有以下配置/文件:

The PL/SQL Method: PL / SQL方法:

PROCEDURE re_pr_ins_apunte_ref ( p_seqrec     IN   RE_T_GE_RECEPTIVO.seq_rec%TYPE,
                             p_seqres     IN   NUMBER,
                             p_importe    IN   NUMBER,
                             p_divisa     IN   gn_t_divisa.cod_divisa%TYPE, 
                             p_codref     IN   RE_T_AD_LIBRO_AGENCIA.cod_referencia_pago%TYPE, 
                             p_codest     IN   RE_T_CD_ESTADO_COBRO.cod_estado%TYPE,
                             p_codpas     IN   RE_T_CD_ESTADO_COBRO.cod_pasarela%TYPE,
                             po_ok        OUT  BOOLEAN, 
                             po_error     OUT  VARCHAR2,  
                             p_autonomous IN   BOOLEAN := TRUE,                                  p_merchant_id IN RE_T_AD_LIBRO_AGENCIA.merchant_id%TYPE DEFAULT NULL
                          ) IS

XML MyBatis Repository select operation: XML MyBatis存储库选择操作:

<select id="agencyBookPostingLineInsRefCall"
            parameterType="com.hotelbeds.commonbookingservice.entity.confirmation.agencybookpostingline.AgencyBookPostingLineInsIOWrapper"
            statementType="CALLABLE">
        {call Re_Pk_Libro_Agencia.re_pr_ins_apunte_ref(
             #{wrapper.incomingOfficeId,  mode=IN,    jdbcType=INTEGER} => P_SEQREC
            , #{wrapper.bookingNumber,    mode=IN,    jdbcType=INTEGER} => P_SEQRES
            , #{wrapper.amount,           mode=IN,    jdbcType=NUMERIC} => P_IMPORTE
            , #{wrapper.currencyId,       mode=IN,    jdbcType=VARCHAR} => P_DIVISA
            , #{wrapper.referenceCode,    mode=IN,    jdbcType=VARCHAR} => P_CODREF
            , #{wrapper.paymentStatus,    mode=IN,    jdbcType=VARCHAR} => P_CODEST
            , #{wrapper.paymentGatewayId, mode=IN,    jdbcType=VARCHAR} => P_CODPAS
            , #{wrapper.ok,               mode=OUT,   jdbcType=VARCHAR, typeHandler=com.hotelbeds.commonbookingservice.db.handler.BooleanTrueFalseTypeHandler}
=> PO_OK
            , #{wrapper.error,            mode=OUT,   jdbcType=VARCHAR }
=> PO_ERROR
            , #{wrapper.autonomous,       mode=IN,    jdbcType=VARCHAR, typeHandler=com.hotelbeds.commonbookingservice.db.handler.BooleanTrueFalseTypeHandler}
=> P_AUTONOMOUS
            , #{wrapper.merchantId,       mode=IN,    jdbcType=VARCHAR} => P_MERCHANT_ID
            )
        }
    </select>

Method in interface class 接口类中的方法

[...]

void agencyBookPostingLineInsRefCall(@Param("wrapper") AgencyBookPostingLineInsIOWrapper wrapper);

[...]

The Wrapper Class for parameters: 包装器类的参数:

/**
 * Wrapper for the method AgencyBookPostingLineIns
 */
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
public class AgencyBookPostingLineInsIOWrapper implements Serializable {

/** The Constant serialVersionUID. */
private static final long serialVersionUID = -6621442227563572393L;

/** Input */
private Integer incomingOfficeId;
private Integer bookingNumber;
private BigDecimal amount;
private String currencyId;
private String referenceCode;
private String paymentStatus;
private String paymentGatewayId;
private Boolean autonomous;
private String merchantId;

/** Output */
private Boolean ok;
private String error;

Boolean Type Handler: 布尔类型处理程序:

/**
 * Example with values true,false to boolean Handler.
 */
@MappedTypes(Boolean.class)
public class BooleanTrueFalseTypeHandler extends AbstractBooleanTypeHandler {



    /** The Constant FALSE_STRING. */
    private static final String FALSE_STRING = "false";

    /** The Constant TRUE_STRING. */
    private static final String TRUE_STRING = "true";

    /**
     * The constructor
     */
    public BooleanTrueFalseTypeHandler() {
        super();
        falseString = FALSE_STRING;
        trueString = TRUE_STRING;
    }
}

And The error: 错误:

==>  Preparing: {call Re_Pk_Libro_Agencia.re_pr_ins_apunte_ref( ? => P_SEQREC , ? => P_SEQRES , ? => P_IMPORTE , ? => P_DIVISA , ? => P_CODREF , ? => P_CODEST , ? => P_CODPAS , ? => PO_OK , ? => PO_ERROR , ? => P_AUTONOMOUS , ? => P_MERCHANT_ID ) } 
==> Parameters: 1(Integer), 3527758(Integer), 200(BigDecimal), EUR(String), 051609100(String), T(String), BIB(String), true(String), MERCHAN(String)
org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLException: ORA-06550: línea 1, columna 7:
PLS-00306: wrong number or types of arguments in call to 'RE_PK_LIBRO_AGENCIA.RE_PR_INS_APUNTE_REF(P_SEQREC, P_SEQRES, P_IMPORTE, P_DIVISA, P_CODREF, P_CODEST, P_CODPAS, PO_OK, PO_ERROR, P_AUTONOMOUS, P_MERCHANT_ID)'
ORA-06550: línea 1, columna 7:
PL/SQL: Statement ignored

### The error may exist in com/hotelbeds/commonbookingservice/db/repository/booking/BookingReconfirmationRepository.xml
### The error may involve com.hotelbeds.commonbookingservice.db.repository.booking.BookingReconfirmationRepository.agencyBookPostingLineInsRefCall-Inline
### The error occurred while setting parameters
### SQL: {call Re_Pk_Libro_Agencia.re_pr_ins_apunte_ref(              ? => P_SEQREC             , ? => P_SEQRES             , ? => P_IMPORTE             , ? => P_DIVISA             , ? => P_CODREF             , ? => P_CODEST             , ? => P_CODPAS             , ? => PO_OK             , ? => PO_ERROR             , ? => P_AUTONOMOUS             , ? => P_MERCHANT_ID             )         }
### Cause: java.sql.SQLException: ORA-06550: línea 1, columna 7:
PLS-00306: wrong number or types of arguments in call to 'RE_PK_LIBRO_AGENCIA.RE_PR_INS_APUNTE_REF(P_SEQREC, P_SEQRES, P_IMPORTE, P_DIVISA, P_CODREF, P_CODEST, P_CODPAS, PO_OK, PO_ERROR, P_AUTONOMOUS, P_MERCHANT_ID)'
ORA-06550: línea 1, columna 7:
PL/SQL: Statement ignored

; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-06550: línea 1, columna 7:
PLS-00306: wrong number or types of arguments in call to 'RE_PK_LIBRO_AGENCIA.RE_PR_INS_APUNTE_REF(P_SEQREC, P_SEQRES, P_IMPORTE, P_DIVISA, P_CODREF, P_CODEST, P_CODPAS, PO_OK, PO_ERROR, P_AUTONOMOUS, P_MERCHANT_ID)'
ORA-06550: línea 1, columna 7:
PL/SQL: Statement ignored

I thing the problem is related with the 2 OUT parameters. 我认为问题与2个OUT参数有关。

The problem is suppoused to be because of the stored procedure BOOLEAN out parameter: 该问题推测是由于存储过程的BOOLEAN out参数:

  • po_ok OUT BOOLEAN. po_ok疯了。

There is a known problem with PL/SQL BOOLEANS in ORACLE Jdbc. ORACLE Jdbc中的PL / SQL BOOLEANS存在一个已知问题。

http://docs.oracle.com/cd/A87861_01/NT817EE/java.817/a83723/typesup1.htm http://docs.oracle.com/cd/A87861_01/NT817EE/java.817/a83723/typesup1.htm


Wrapping PL/SQL BOOLEAN, RECORD, and TABLE Types 包装PL / SQL BOOLEAN,RECORD和TABLE类型

Oracle JDBC drivers do not support calling arguments or return values of the PL/SQL types TABLE (now known as indexed-by tables), RECORD, or BOOLEAN. Oracle JDBC驱动程序不支持PL / SQL类型TABLE(现在称为索引表),RECORD或BOOLEAN的调用参数或返回值。

As a workaround, you can create wrapper procedures that handle the data as types supported by JDBC. 解决方法是,可以创建包装程序,将数据作为JDBC支持的类型来处理。 For example, to wrap a stored procedure that uses PL/SQL booleans, you can create a stored procedure that takes a character or number from JDBC and passes it to the original procedure as BOOLEAN, or, for an output parameter, accepts a BOOLEAN argument from the original procedure and passes it as a CHAR or NUMBER to JDBC. 例如,要包装使用PL / SQL布尔值的存储过程,可以创建一个存储过程,该存储过程从JDBC中获取一个字符或数字,并将其作为BOOLEAN传递给原始过程,或者对于输出参数,接受BOOLEAN参数从原始过程中获取,并将其作为CHAR或NUMBER传递给JDBC。 Similarly, to wrap a stored procedure that uses PL/SQL records, you can create a stored procedure that handles a record in its individual components (such as CHAR and NUMBER). 同样,要包装使用PL / SQL记录的存储过程,可以创建一个存储过程来处理其各个组件(例如CHAR和NUMBER)中的记录。 To wrap a stored procedure that uses PL/SQL tables, you can break the data into components or perhaps use Oracle collection types. 要包装使用PL / SQL表的存储过程,可以将数据分解为组件,也可以使用Oracle集合类型。

I've had to implement a PL/SQL wrapper procedure that check de BOOLEAN value and which returns a VARCHAR to Java with jdbc connector. 我必须实现一个PL / SQL包装程序,该程序检查de BOOLEAN值,并使用jdbc连接器将VARCHAR返回到Java。

PROCEDURE re_pr_ins_apunte_ref_w ( p_seqrec     IN   RE_T_GE_RECEPTIVO.seq_rec%TYPE, -- Oficina que gestiona el apunte
                                  p_seqres     IN   NUMBER,  -- Reserva
                                 p_importe    IN   NUMBER, -- Importe Haber.
                                 p_divisa     IN   gn_t_divisa.cod_divisa%TYPE, 
                                 p_codref     IN   RE_T_AD_LIBRO_AGENCIA.cod_referencia_pago%TYPE, -- Referencia de pago.
                                 p_codest     IN   RE_T_CD_ESTADO_COBRO.cod_estado%TYPE,
                                 p_codpas     IN   RE_T_CD_ESTADO_COBRO.cod_pasarela%TYPE,
                                 po_ok        OUT VARCHAR2,                -- Indica si la funcion ha terminado correctamente
                                 po_error     OUT VARCHAR2,
                                 p_autonomous IN  BOOLEAN := TRUE,            -- True: Nextval, False: Nextval_no_autonomous
                                 p_merchant_id IN RE_T_AD_LIBRO_AGENCIA.merchant_id%TYPE DEFAULT NULL

                              ) IS

    vo_ok  BOOLEAN; 

BEGIN

re_pr_ins_apunte_ref(   p_seqrec, -- Oficina que gestiona el apunte
                        p_seqres, -- Secuencia de la venta (seq_reserva, seq_cargo, seq_expediente, seq_contr)
                        p_importe, -- Importe Haber.
                        p_DIVISA, -- Divisa en la que está expresado el importe
                        p_codref, -- Referencia de pago.
                        p_codest,
                        p_codpas,
                        vo_ok,  -- Indica si la funcion ha terminado correctamente
                        po_error,  -- Descripcion del error
                        p_autonomous, -- True: Nextval, False: Nextval_no_autonomous
                        p_merchant_id);

IF (VO_OK) THEN 
    po_ok := 'S';
  ELSE
    po_ok := 'N';
  END IF;

END re_pr_ins_apunte_ref_w;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PLS-00306:Java中对GET_NEW_EVENTS的调用中参数的数量或类型错误 - PLS-00306: wrong number or types of arguments in call to GET_NEW_EVENTS in Java ORA-06550:第1行,第7列:PLS-00306:错误的数量或调用中的参数类型 - ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call 当 Hibernate 看起来正确时,为什么我会收到 PLS-00306“调用中的 arguments 的数量或类型错误”? - Why am I getting PLS-00306 “wrong number or types of arguments in call” when the Hibernate looks correct? 引起:java.sql.SQLException:ORA-06550:第 1 行,第 7 列:PLS-00306:ZDBC11CAA5BDA99F77E6FB4DABD_SPE_FA 7 调用中的 ZDBC11CAA5BDA99F77E6FB4DABD8SPE_7 的错误编号或类型 - Caused by: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'PR_SP_FAHMI' 具有命名绑定的 CallableStatement 导致 PLS-00306:错误的参数数量或类型 - CallableStatement with Named binding leads to PLS-00306: wrong number or types of arguments 休眠PLS-00306错误 - hibernate PLS-00306 error 使用Java调用PL / SQL函数时,类型或参数数量错误。 PLS-00306错误 - Wrong type or number of parameters when calling a PL/SQL function using Java. PLS-00306 error 使用带有布尔 IN 参数的 CallableStatement 在 Java 中调用 Oracle PL/SQL 过程会产生 PLS-00306 oracle 错误: - Calling an Oracle PL/SQL procedure in Java using a CallableStatement with a boolean IN parameter gives an PLS-00306 oracle error: 调用“ DROP_QUEUE_TABLE”时参数的数量或类型错误 - wrong number or types of arguments in call to 'DROP_QUEUE_TABLE' 如何使用 MyBatis 调用 Oracle 数据库序列号? - How to call a Oracle database sequence number by using MyBatis?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM