Menu

bind arrays and overwriting

wadam1972
2009-08-04
2012-09-26
  • wadam1972

    wadam1972 - 2009-08-04

    Hello Vincent!
    I still have a little problem regarding "BIND ARRAYS and OVERWRITING".
    I have attached the sample program (SLES 10 - 64 Bit - OCILIB Version 3.4.0):
    The bind array has 2 positions.
    In the first array execution I have the values "heinz" (pos 0) and "peter" (pos 1).
    Then I make "OCI_Execute".
    In the next array I have the values "karl" (pos 0) and empty string "" (pos 1).
    But in Oracle 10 g I see the values:
    - heinz, peter
    - karl, peter ... and NOT karl, ""
    Thanks in advance
    Wolfgang


    undef _GLIBCPP_USE_LONG_LONG

    ifdef _MSC_VER

    define OCI_API __stdcall

    endif

    include "ocilib.h"

    include <stdio.h>

    include <ctype.h>

    include <locale.h>

    include <sys/stat.h>

    include <string.h>

    OCI_Connection cn;
    OCI_Statement
    st;
    short arr_short[3] = {0, 0, 0};
    wchar_t wcstr[2][11];
    char src_str[50] = "";
    int ret_val;

    define false 0

    define true 1

    int main () {
    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT | OCI_ENV_CONTEXT)) {
    printf("error init\n");
    return EXIT_FAILURE;
    }
    printf("init ok\n");

    cn = OCI_ConnectionCreate("orcl","scott","orac",OCI_SESSION_DEFAULT);
    if (cn == NULL) {
    printf("error conn\n");
    return EXIT_FAILURE;
    }

    st = OCI_StatementCreate(cn);

    setlocale(LC_CTYPE, "de_AT.ISO_8859-1");
    printf("setlocale ok\n");

    ret_val = OCI_Prepare(st, "insert into ink_tet (tet_id, tet_vorname) values (:tet_id, :tet_vorname)");
    if (ret_val == false) {
    printf("error prep\n");
    return EXIT_FAILURE;
    }
    printf("prep ok\n");

    ret_val = OCI_BindArraySetSize(st, 2);
    if (ret_val == false) {
    printf("error set size\n");
    return EXIT_FAILURE;
    }
    printf("set size ok\n");

    OCI_BindArrayOfShorts(st, ":tet_id", arr_short, 0);
    if (ret_val == false) {
    printf("error bind short\n");
    return EXIT_FAILURE;
    }
    printf("bind short ok\n");

    OCI_BindArrayOfStrings(st, ":tet_vorname", (dtext *)wcstr, 10, 0);
    if (ret_val == false) {
    printf("error bind string\n");
    return EXIT_FAILURE;
    }
    printf("bind strings ok\n");

    arr_short[0] = 4;
    strcpy(src_str, "heinz");
    mbstowcs(wcstr[0], src_str, (size_t)strlen(src_str)+1);

    arr_short[1] = 3;
    strcpy(src_str, "peter");
    mbstowcs(wcstr[1], src_str, (size_t)strlen(src_str)+1);

    OCI_Execute(st);
    if (ret_val == false) {
    printf("error execute\n");
    return EXIT_FAILURE;
    }
    printf("execute ok\n");

    OCI_Commit(cn);

    arr_short[0] = 250;
    strcpy(src_str, "karl");
    mbstowcs(wcstr[0], src_str, (size_t)strlen(src_str)+1);

    arr_short[1] = 77;
    strcpy(src_str,"");
    mbstowcs(wcstr[1], src_str, (size_t)strlen(src_str)+1);

    OCI_Execute(st);
    OCI_Commit(cn);

    OCI_Cleanup();

    return 0;
    }

     
    • Vincent Rogier

      Vincent Rogier - 2009-08-21

      hi,

      svn updated...

      Vincent

       
    • Vincent Rogier

      Vincent Rogier - 2009-08-11

      Hello,

      I'll check this issue and fix it for v3.4.1

      Regards,

      Vincent