still problems with overwriting

wadam1972
2009-06-29
2012-09-26
  • wadam1972

    wadam1972 - 2009-06-29

    Hello Vincent!
    Can you help me. I have still problems with overwriting when working with bind arrays.
    I use linux64 and the newest ocilib from source forge svn (3.3.0 2009-06-23).
    Here is my example program. The 4th entry in my oracle db is still not "xml" but "xmlglongtx".
    Thanks in advance
    Wolfgang

    undef _GLIBCPP_USE_LONG_LONG

    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

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

    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");

    ret_val = OCI_Prepare(st, "insert into ink_per (per_id, per_str) values (:per_id, :per_str)");
    if (ret_val == false) {
    printf("error prep\n");
    return EXIT_FAILURE;
    }

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

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

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

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

    arr_short[0] = 3;
    strcpy(src_str, "longlongtx");
    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;
    }

    OCI_Commit(cn);

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

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

    OCI_Execute(st);
    OCI_Commit(cn);

    OCI_Cleanup();
    }

     
    • Vincent Rogier

      Vincent Rogier - 2009-06-29

      Hi wolfgang,

      i could reproduced the bug with your test case.

      I've fixed it and now your tesrt case runs ok !

      I've just updated the svn (rev 64)

      Can you confirm it's okay for you ?

      Thanks.

       
    • Nobody/Anonymous

      Hello Vincent!
      Thank you for your fast answer and your help.
      Now it works.
      Thanks
      Wolfgang

       
      • Vincent Rogier

        Vincent Rogier - 2009-06-29

        good :)

        Vincent.