无法创建JDBC VARCHAR2串甲骨文ARRAY [英] Couldn't create String Oracle ARRAY of varchar2 in JDBC

查看:192
本文介绍了无法创建JDBC VARCHAR2串甲骨文ARRAY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原谅我的英语不好(愚蠢的法国人!:P)

excuse me for my bad english (stupid french people!! :p )

我创建2个类型的:

create or replace TYPE LISTE_ENQUETE AS TABLE OF VARCHAR2(500);    

create or replace TYPE LISTE_IDE_ENQUETE AS TABLE OF VARCHAR2(500);

和我在存储过程中PS_MAJ_QUALITE2.sql使用它们:

and I use them in my stored procedure PS_MAJ_QUALITE2.sql:

create or replace PROCEDURE PS_MAJ_QUALITE2 (
                   w_LISTE IN LISTE_ENQUETE,
                   w_PART IN VARCHAR2,
                   w_TYPE IN VARCHAR2,
                   w_ID_ENQ IN VARCHAR2,
                   w_CATEGORIE IN VARCHAR2,
                   w_LISTE_IDE IN LISTE_IDE_ENQUETE
                   )
IS.......

我的Java code是:

My Java code is:

private void appelerPS_MAJ_QUALITE2(String partieEnquete, Connection c, String[]tabEntete, String type, String categorie, String ideEnquete, String[]tabIde) throws TechnicalException {
    String sReq = "{call ps_MAJ_QUALITE2(?,?,?,?,?,?)}";
    CallableStatement cstmt = null;

    try {

        java.sql.Array sqlArray = null;
        ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor("LISTE_ENQUETE", c);
        sqlArray = new oracle.sql.ARRAY(arrayDescriptor, c, tabEntete);

        java.sql.Array sqlArrayIde = null;
        ArrayDescriptor arrayDescriptor2 = ArrayDescriptor.createDescriptor("LISTE_IDE_ENQUETE", c);
        sqlArrayIde = new oracle.sql.ARRAY(arrayDescriptor2, c, tabIde);

        // Préparation de l'appel à la procédure stockée
        cstmt = c.prepareCall(sReq);
        cstmt.clearParameters();
        // alimentation du code traitement :
        cstmt.setArray(1, sqlArray);
        cstmt.setString(2, partieEnquete);
        cstmt.setString(3, type);
        cstmt.setString(4, ideEnquete);
        cstmt.setString(5, categorie);
        cstmt.setArray(6, sqlArrayIde);

        cstmt.execute();

    } catch (SQLException e) {...}
.......
}

我的String [] tabEntete和的String [] tabIde选项卡具有良好的信息,但是当我在寻找sqlArray和sqlArrayIde内容,我:???,???,??? ]。

My String[] tabEntete and String[]tabIde tabs have the good informations but when I'm looking sqlArray and sqlArrayIde contents, I have: ["???", "???", "???"].

当我尝试插入sqlArray的数据或sqlArrayIde'data我有错误:

and when I try to insert sqlArray's data or sqlArrayIde'data I have the error:

Error executing the stored procedure PS_MAJ_QUALITE, exception message :  ORA-01400: cannot insert NULL into ("WFGA_PM_ASS1"."REPONSE_FORMULAIRE_QUALITE"."IDE_REPONSE")

能否请你帮我解决这个问题。
非常感谢你的帮助。

Could you please help me to solve this problem. Thank you very much for your help.

Yohann

推荐答案

(带哟翰自己的解决方案回答,因为它帮助我太)

(answering with Yo hann's own solution, as it helped me too)

使用NVARCHAR2为您的新类型,而不是VARCHAR2。

Use NVARCHAR2 for your new type instead of VARCHAR2.

这篇关于无法创建JDBC VARCHAR2串甲骨文ARRAY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆