[R] Q

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Sun 01 Apr 2007 - 12:56:40 GMT

On 4/1/2007 3:39 AM, Prof Brian Ripley wrote:
> I think this is about RODBC, uncredited.
> There is currently no way to do escapes here, and I am pretty sure that
> ODBC drivers do not support 'slash' as an escape (or did you mean
> backslash? I am still not sure that would work).
> sqlSave() has fast=TRUE and fast=FALSE options, and it is worth trying
> both. Since the default fast=TRUE passes character data as binary fields,
> I don't understand why there is a problem (there might be for fast=FALSE
> with single quotes in character fields).

SQL doubles quotes to escape them, doesn't it? I.e. if I wanted

this 'value'

as an SQL literal, I would use

'this ''value'''

I think this is described in the SQL 92 standard (it defines <quote symbol> ::= <quote><quote>), but I don't know if it is universally implemented. So if this syntax is supported in Laurent's driver/DBMS combination, he could simply double the quotes himself before trying to save them, i.e.

values <- gsub("'", "''", values)

Duncan Murdoch

> Without any relevant details (OS, R version, packages used, package
> version, ODBC driver, DBMS) and any sort of example it is really hard to
> offer help: please DO study the R posting guide (and note also the comment
> about using a signature block).
> On Sat, 31 Mar 2007, Laurent Valdes wrote:
>> Hi everybody,
>> I'm doing a sqlSave() in R, to insert a big data frame of 10000 rows.
>> However, there is problems, since several rows contains quotations marks,
>> that can leave inserts buggy.
>> I would like to find a way to add slashes in front of these quotation marks.
>> Best regards,
>> Laurent

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun Apr 01 23:01:50 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 03 Apr 2007 - 08:30:47 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.