Re: [HACKERS] Getting number of tuples affected
От | Michael Richards |
---|---|
Тема | Re: [HACKERS] Getting number of tuples affected |
Дата | |
Msg-id | Pine.BSF.4.10.9906301124010.12242-100000@scifair.acadiau.ca обсуждение исходный текст |
Ответ на | Re: [HACKERS] Getting number of tuples affected (Vince Vielhaber <vev@michvhf.com>) |
Ответы |
Re: [HACKERS] Getting number of tuples affected
|
Список | pgsql-hackers |
On Wed, 30 Jun 1999, Vince Vielhaber wrote: > > I was looking for a function to return the number of tuples an update > > returned, but couldn't find anything for libpq++. Any ideas? > > Added to my list of stuff to do. As to what else you can do, submit > patches? :) > > There is no PgDatabase::exec > Yep. Guess that should be data.Exec(... Not sure there is an Exec either :) I've been making a pile of changes to the PgDatabase class. (Actually I derived it). One such change is a function to quote a string you're going to use in SQL. I'm not sure if this belongs in the PgDatabase class, but if you think so, I'll add it before I submit the tuple count patches. This allows me to do something like: String updatesql(form("UPDATE users SET lastrequest='now' WHERE loginid=%s",dbh->quote(_username).chars())); cout << dbh->ExecTuplesOk(updatesql); That is actually the call I needed the update count to ensure it worked... Here is the routine: // routine to quote any \ or ' chars in the passed string // this isn't too efficient, but how much data are we really quoting? String TDatabase::quote(const char *dirty) { // start with a single quote String clean("'"); const char *strptr=dirty; // escape the string if it contains any ' or \ chars while (*strptr) { if ((*strptr=='\'') ||(*strptr=='\\')) clean+='\\'; clean+=*(strptr++); } // end with a quote clean+="'"; return clean; } -Michael
В списке pgsql-hackers по дате отправления: