// Copyright (c) 1999-2001 David Muse // See the file COPYING for more information #include #include stringbuffer *sqlrcursor_svr::fakeInputBinds(const char *query) { // return null if there aren't any input binds if (!inbindcount) { return NULL; } stringbuffer *outputquery=new stringbuffer(); // loop through the query, performing substitutions char prefix=inbindvars[0].variable[0]; char *ptr=(char *)query; int index=1; bool inquotes=false; while (*ptr) { // are we inside of quotes ? if (*ptr=='\'') { if (inquotes) { inquotes=false; } else { inquotes=true; } } // look for the bind var prefix or ? if not inside of quotes if (!inquotes && (*ptr==prefix || *ptr=='?')) { // look through the list of vars for (int16_t i=0; iappend(*ptr); ptr++; } } return outputquery; } void sqlrcursor_svr::performSubstitution(stringbuffer *buffer, int16_t index) { if (inbindvars[index].type==STRING_BIND) { buffer->append("'"); size_t length=inbindvars[index].valuesize; for (size_t ind=0; indappend('\\'); } else if (ch=='\0') { buffer->append("\\0"); } buffer->append(ch); } buffer->append("'"); } else if (inbindvars[index].type==INTEGER_BIND) { buffer->append(inbindvars[index].value.integerval); } else if (inbindvars[index].type==DOUBLE_BIND) { buffer->append(inbindvars[index].value.doubleval.value, inbindvars[index].value.doubleval.precision, inbindvars[index].value.doubleval.scale); } else if (inbindvars[index].type==NULL_BIND) { buffer->append("NULL"); } }