我需要使用OCIBindByPos和OCIBindArrayOfStruct将记录插入到一个表中。一个简单的表,一列为ID,一列为Value。一次插入5条记录,使用OCIBindByPos和OCIBindArrayOfStruct如何实现?
另外:OCIBindByPos ( OCIStmt      *stmtp,  
                     OCIBind      **bindpp, 
                     OCIError     *errhp, 
                     ub4          position,// 绑定的位置 
                     dvoid        *valuep, 
                     sb4          value_sz, 
                     ub2          dty, 
                     dvoid        *indp, 
                     ub2          *alenp, 
                     ub2          *rcodep, 
                     ub4          maxarr_len, 
                     ub4          *curelep,  
                     ub4          mode ); 在我的这个问题中该传入什么样的参数呀?我不明白这三个参数的意义,Oracle以前也没用过,希望各位帮忙,能否给出代码来实习这个需求。

解决方案 »

  1.   

    sword OCIBindByPos ( OCIStmt      *stmtp, 
                        OCIBind      **bindpp, 
                        OCIError     *errhp, 
                        ub4          position, // 绑定的位置 
                           dvoid        *valuep,  //缓冲区地址
                        sb4          value_sz, //一条记录的长度
                        ub2          dty,      //在OCI中的数据类型
                        dvoid        *indp,    //是否为空的标志
                        ub2          *alenp, 
                        ub2          *rcodep, 
                        ub4          maxarr_len, 
                        ub4          *curelep, 
                        ub4          mode ); 
      

  2.   

    sword OCIBindByName ( 
    OCIStmt       *stmtp, //语句句柄 
                    OCIBind       **bindpp,//结合句柄,=NULL 
                  OCIError      *errhp, 
                  CONST text    *placeholder,//占位符名称 
                    sb4           placeh_len, //占位符长度 
                    dvoid         *valuep, //绑定的变量名 
                    sb4           value_sz, //绑定的变量名长度 
                    ub2           dty,  //绑定的类型 
                    dvoid         *indp, //指示符变量指针(sb2类型),单条绑定时为NULL, 
                  ub2           *alenp, //说明执行前后被结合的数组变量中各元素数据实际的长度,单条绑定时为NULL 
                  ub2           *rcodep,//列级返回码数据指针,单条绑定时为NULL 
                  ub4           maxarr_len, //最多的记录数,如果是单条绑定,则为0 
                  ub4           *curelep, //实际的记录数,单条绑定则为NULL 
                  ub4           mode //=OCI_DEFAULT 
    );