#define SQL_TEXT Latin_Text #include <sqltypes_td.h> #include <string.h> void xsp_getregion ( VARCHAR_LATIN *region, int *region_isnull, char sqlstate[6], SQL_TEXT extname[129], SQL_TEXT specific_name[129], SQL_TEXT error_message[257]) { char tmp_string[64]; void *argv[2]; int ind[2]; parm_t dtype[2]; INTEGER regionCount; /* OUT argument from addRegion */ /* Set the return indicator value for the external stored procedure*/ *region_isnull = 0; if (strlen((const char *)region) > 4) { /* Strip off the first four characters */ strcpy(tmp_string, (char *)region); strcpy((char *)region, &tmp_string[4]); /* Set the pointers to the stored procedure arguments */ argv[0] = region; /* IN */ argv[1] = ®ionCount; /* OUT */ /* Set the indicator for the IN argument */ ind[0] = 0; memset(dtype, 2, sizeof(parm_t)*2); /* Data type for the VARCHAR IN argument */ dtype[0].datatype = VARCHAR_DT; dtype[0].direction = IN_PM; dtype[0].charset = LATIN_CT; dtype[0].size.length = strlen((const char *)region); /* Data type for the INTEGER OUT argument */ dtype[1].datatype = INTEGER_DT; dtype[1].direction = OUT_PM; FNC_CallSP((SQL_TEXT *)"addRegion", 2, argv, ind, dtype, sqlstate); if (strcmp(sqlstate, "00000") != 0) { strcpy((char *)error_message, "Bad call to addRegion"); return; } } else { strcpy(sqlstate, "U0001"); strcpy((char *)error_message, "Region string too short"); return; } }