ITQuants blog

Sophis Risque: how to use the CSRSqlQuery::MultipleWrite method?

Feb 20

Written by:
2/20/2014 6:39 PM  RssIcon

The Sophis API provides a method, CSRSqlQuery::MultipleWrite, which enables the developer to insert several records in one command, using arrays. Unfortunately, the method doesn't work fine if an error occurs during an insertion. In this case, next calls to this method will return unpredictable results, like not data found:

 This error occurs in fact only when the optional parameter that corresponds to the Oracle cursor is not filled. In this case, the global one which is used remains in uncertain state after the error. This error occurs at least on 5.3.4, 5.3.7 versions of Sophis Risque.

The workaround is in fact quite easy: we just need to not use the global cursor but a local one. The following code permits to resolve such a problem:

errorCode MultipleWrite(const char *query,
                                const char *name,
                                const sophis::sql::CSRStructureDescriptor *vars,
                                char * values,
                                int num_rows)
{
    sophis::sql::CSCurseurDB _cursor;
    return CSRSqlQuery::MultipleWrite(query,name,&_cursor,vars,values,num_rows);
}

Search blog