I tried 

    char *v_char[] = {"Y\0N\0Y\0"}; // array of strings                   
    int v_char_off[] = {0, 2, 4};        // offsets for strings

    // append string heaps 
    size_t toff = tmp3->batCount == 0 ? 0 : tmp3->tvheap->free;
    // make sure we get alignment right 
    toff = (toff + GDK_VARALIGN - 1) & ~(GDK_VARALIGN - 1);
    
    //create a heap of strings
    HEAPextend(tmp3->tvheap, toff + nrows*(sizeof(char)+1), 1);
    memcpy(tmp3->tvheap->base + toff, v_char, nrows*(sizeof(char)+1));

    tmp3->tvheap->free = toff + nrows*(sizeof(char)+1);
    BATsetcount(tmp3, BATcount(tmp3) + nrows);

    //integers to point into a heap of strings
    memcpy(Tloc(tmp3, BUNlast(tmp3)), v_char_off, nrows*sizeof(int));

but output string column is empty.

Anton

On Fri, Nov 2, 2018 at 2:08 PM Anton Kravchenko <kravchenko.anton86@gmail.com> wrote:
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