Problem with palo_getdata_area in C Api

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Problem with palo_getdata_area in C Api

    Hello!
    I want create query to cube Sales in database Demo.
    THis is fragment of my program:

    Source Code

    1. //global variables
    2. struct sock_obj so; //identification of connection
    3. struct conversions convs; //conversions
    4. int main() { //main function
    5. //...
    6. libpalo_err err; //code of error
    7. char **coord_strs; //strings containing names of dimension elements
    8. struct arg_str_array_m *coordinates; //coordinates for query
    9. struct arg_str_array_array_m coordinates_array; //array of coordinates
    10. struct arg_palo_value_array_m subcube; //"sub-cube" from the PALO server
    11. //...
    12. //initialization, connection e.t.c.
    13. coord_strs=(char**)malloc(6*sizeof(char*));
    14. coord_strs[0]=strdup("Desktop L");
    15. coord_strs[1]=strdup("Germany");
    16. coord_strs[2]=strdup("Jan");
    17. coord_strs[3]=strdup("2002");
    18. coord_strs[4]=strdup("Budget");
    19. coord_strs[5]=strdup("Units");
    20. coordinates=(struct arg_str_array_m*)malloc(1*sizeof(struct arg_str_array_m));
    21. coordinates[0]=libpalo_make_arg_str_array_m(6, (const char**)coord_strs);
    22. coordinates_array=libpalo_make_arg_str_array_array_m(1, coordinates);
    23. if (!LIBPALO_SUCCESSFUL(palo_getdata_area_m_r(&err, &subcube, &so, &convs, "Demo", "Sales", coordinates_array, ""))) myapp_handle_error(&err); //error here
    Display All


    I get an error: not the correct amount of dimensions (Error -27)

    But if I try to get 1 value from Palo server, all is ok:

    Source Code

    1. //global variables
    2. struct sock_obj so; //identification of connection
    3. struct conversions convs; //conversions
    4. int main() { //main function
    5. //...
    6. libpalo_err err; //code of error
    7. char **coord_strs; //strings containing names of dimension elements
    8. struct arg_str_array_m coord; //coordinates
    9. struct arg_palo_value_m subcube_value; //1 value from cube
    10. //...
    11. //initialization, connection e.t.c.
    12. coord_strs=(char**)malloc(6*sizeof(char*));
    13. coord_strs[0]=strdup("Desktop L");
    14. coord_strs[1]=strdup("Germany");
    15. coord_strs[2]=strdup("Jan");
    16. coord_strs[3]=strdup("2002");
    17. coord_strs[4]=strdup("Budget");
    18. coord_strs[5]=strdup("Units");
    19. coord=libpalo_make_arg_str_array_m(6, (const char**)coord_strs);
    20. if (!LIBPALO_SUCCESSFUL(palo_getdata_m_r(&err, &subcube_value, &so, &convs, "Demo", "Sales", coord))) myapp_handle_error(&err); //no error here
    Display All

    Whats wrong?

    The post was edited 1 time, last by crop ().

  • RE: Problem with palo_getdata_area in C Api

    Hi,
    I'm not quite sure but I think when you retrieve a data area you need two more args for number of rows and cols. There is a similar question at the following thread. It concerned php api but means the same. May it helps.

    Greetings from Cologne
    Holger

    The post was edited 1 time, last by h_decker ().

  • And what should I write in coord_strs in my example? coord_strs is char**, but in php example it is array containing from set of dimension elements and 2 additional parameters (number of columns and number of rows). I think this solution is not for C. I will try palo_getdata_multi.
    p.s. it will good if Palo team make new C example in next release of Palo with demonstaration of all functions and palo_getdata_area in particulary. And don't forget to update documentation of Api, please, make it more detail and clear.

    The post was edited 1 time, last by crop ().

  • I solved problem with number of dimensions myself. But I get another error. Here is my code:

    Source Code

    1. //global variables
    2. struct sock_obj so; //identification of connection
    3. struct conversions convs; //conversions
    4. int main() { //main function
    5. //...
    6. libpalo_err err; //code of error
    7. char **coord_strs; //strings containing names of dimension elements
    8. struct arg_str_array_m *coordinates; //coordinates for query
    9. struct arg_str_array_array_m coordinates_array; //array of coordinates
    10. struct arg_palo_value_array_m subcube; //"sub-cube" from the PALO server
    11. //...
    12. //initialization, connection e.t.c.
    13. coordinates=(struct arg_str_array_m*)malloc(6*sizeof(struct arg_str_array_m));
    14. coord_strs=(char**)malloc(1*sizeof(char*));
    15. coord_strs[0]=strdup("Desktop L");
    16. coordinates[0]=libpalo_make_arg_str_array_m(1, (const char**)coord_strs);
    17. free(*coord_strs);
    18. coord_strs[0]=strdup("Germany");
    19. coordinates[1]=libpalo_make_arg_str_array_m(1, (const char**)coord_strs);
    20. free(*coord_strs);
    21. coord_strs[0]=strdup("Jan");
    22. coordinates[2]=libpalo_make_arg_str_array_m(1, (const char**)coord_strs);
    23. free(*coord_strs);
    24. coord_strs[0]=strdup("2002");
    25. coordinates[3]=libpalo_make_arg_str_array_m(1, (const char**)coord_strs);
    26. free(*coord_strs);
    27. coord_strs[0]=strdup("Budget");
    28. coordinates[4]=libpalo_make_arg_str_array_m(1, (const char**)coord_strs);
    29. free(*coord_strs);
    30. coord_strs[0]=strdup("Units");
    31. coordinates[5]=libpalo_make_arg_str_array_m(1, (const char**)coord_strs);
    32. free(*coord_strs);
    33. free(coord_strs);
    34. coordinates_array=libpalo_make_arg_str_array_array_m(6, coordinates);
    35. printf("Name of first dimension element of first dimension: %s\n", coordinates_array.a[0].a[0]); //error here, "???..." instead of correct symbols
    36. if (!LIBPALO_SUCCESSFUL(palo_getdata_area_m_r(&err, &subcube, &so, &convs, "Demo", "Sales", coordinates_array, ""))) olview_handle_error(&err); //doesn't work because wrong names of dimensions
    Display All

    It seems that libpalo_make_arg_str_array_array_m doesn't work properly.
    Where is my mistake?
  • I solved my problem. Solution was very simple :D

    Source Code

    1. //global variables
    2. struct sock_obj so; //identification of connection
    3. struct conversions convs; //conversions
    4. int main() { //main function
    5. //...
    6. libpalo_err err; //code of error
    7. struct arg_str_array_m *coordinates; //coordinates for query
    8. struct arg_str_array_array_m coordinates_array; //array of coordinates
    9. struct arg_palo_value_array_m subcube; //"sub-cube" from the PALO server
    10. //...
    11. //initialization, connection e.t.c.
    12. coordinates=(struct arg_str_array_m*)malloc(6*sizeof(struct
    13. arg_str_array_m));
    14. for (i=0; i<6; i++) {
    15. coordinates[i].len=1;
    16. coordinates[i].a=(char**)malloc(sizeof(char*));
    17. }
    18. coordinates[0].a[0]=strdup("Desktop L");
    19. coordinates[1].a[0]=strdup("France");
    20. coordinates[2].a[0]=strdup("Jan");
    21. coordinates[3].a[0]=strdup("2002");
    22. coordinates[4].a[0]=strdup("Budget");
    23. coordinates[5].a[0]=strdup("Units");
    24. coordinates_array=libpalo_make_arg_str_array_array_m(6, coordinates);
    25. for (i=0; i<6; i++)
    26. printf("Dimension %d: %s<br />\n", i+1, coordinates_array.a[i].a[0]);
    27. if (!LIBPALO_SUCCESSFUL(palo_getdata_area_m_r(&err, &subcube, &so, &convs, "Demo", "Sales", coordinates_array, ""))) olview_handle_error(&err);
    28. printf("Server answer: %f<br />\n", subcube.a[0].val.d);
    Display All


    libpalo_make_arg_str_array and libpalo_make_arg_str_array_array functions didn't duplicate data, they only set pointers to existing data (surface copying of pointers).

    The post was edited 1 time, last by crop ().