Though I wonder how  to append an array of values to a BUN for TYPE_str column?

    sql_table *tbl = mvc_bind_table(m, sch, "atable");

    sql_column *col1 = mvc_bind_column(m, tbl, "acolumn"); //char(1)

    BAT *tmp1 = NULL;

    int nrows = 3;

    tmp1 = COLnew(0, TYPE_str, (BUN)nrows, TRANSIENT);


    char v_char[3][2] = {"Y\0","N\0","Y\0"};               //char(1)

    for (irow=0; irow<nrows; irow++) 

      BUNappend(tmp1, &(v_char[irow]), FALSE);

    

    mvc_append_column(m->session->tr, col1, tmp1);

    mvc_commit(m, 0, tr->name);

    bat_destroy(tmp1);


Anton 


On Fri, Nov 2, 2018 at 1:12 PM Anton Kravchenko <kravchenko.anton86@gmail.com> wrote:
Ok to make it work I had to replace

for (irow=0; irow<nrows; irow++) 

     BUNappend(tmp1, &v_long[irow], FALSE);


 with 


memcpy(Tloc(tmp1, BUNlast(tmp1)), v_long, nrows*sizeof(long long)); 

BATsetcount(tmp1, BATcount(tmp1) + nrows);


 Anton 


On Fri, Nov 2, 2018 at 9:39 AM Anton Kravchenko <kravchenko.anton86@gmail.com> wrote:
Hi there,

Is there a way to append an array of values to a BUN, instead one value at a time?

sql_table *tbl = mvc_bind_table(m, sch, "atable");

sql_column *col = mvc_bind_column(m, tbl, "acolumn");     
BAT *tmp1 = COLnew(0, TYPE_lng, (BUN)nrows, TRANSIENT);    
long long v_long[3] = {100000000009,100000000010,100000000011}; 

for (irow=0; irow<nrows; irow++) 

     BUNappend(tmp1, &v_long[irow], FALSE);


mvc_append_column(m->session->tr, col1, tmp1);    

mvc_commit(m, 0, tr->name);

bat_destroy(tmp1);


Thanks,
Anton