[R-sig-DB] Add a "dbSendUpdate" function to DBI?

Peter Meißner peter@me|@@ner @end|ng |rom un|-kon@t@nz@de
Thu Sep 4 16:45:30 CEST 2014


IMHO

the general approach should be:

- as long as R does deliver the the queries to the DB and the DB does 
give response there should never ever be an R error - the function did 
what it should do: making sure things were delivered to DB

- the return than should depend on what the DB said:
   * 0/TRUE                    - no error, nothing else to say
   * 1/FALSE                   - DB does complain somehow
   * text/whatever appropriate - something was returned, ...

- if however connection was lost during the execution of the function so 
it cannot be sure delivery went as expected an error should be issued

Best, Peter



Am 04.09.2014 16:28, schrieb Denis Mukhin:
> In ROracle we standardized on the second approach, namely always return TRUE, otherwise throw an error.
>
> Also since UPDATE is not the only operation that does not return any results (although it might with a RETURNING clause) would a more generic name be more appropriate here? Besides DMLs there are also DDLs. Something like dbExecute(), dbSubmit(), dbSend() ...
>
> Denis
>
> -----Original Message-----
> From: Hadley Wickham [mailto:hadley using rstudio.com]
> Sent: Thursday, September 04, 2014 9:13 AM
> To: MacQueen, Don
> Cc: Simon Urbanek; R-sig-DB using r-project.org
> Subject: Re: [R-sig-DB] Add a "dbSendUpdate" function to DBI?
>
> A thought: should dbSendUpdate() return a boolean indicating success, or always return TRUE, otherwise throwing an error?
>
> Hadley
>
> On Wed, Sep 3, 2014 at 3:59 PM, MacQueen, Don <macqueen1 using llnl.gov> wrote:
>> Hadley,
>>
>> Since you mentioned DBI 0.3 in a recent email, could I make a request
>> to add a dbSendUpdate() function to DBI, like the one in RJDBC?
>>
>> require(RJDBC)
>>
>>> find('dbSendQuery')
>> [1] "package:RJDBC" "package:DBI"
>>
>>> find('dbSendUpdate')
>> [1] "package:RJDBC"
>>
>> And from ?dbSendUpdate
>>
>>    'dbSendQuery' and 'dbSendUpdate' submit a SQL query to the
>>    database. The difference between the two is only that
>>    'dbSendUpdate' is used with DBML queries and thus doesn't return
>>    any result set.
>>
>> I would find this helpful, because I could then use scripts unmodified
>> with either ROracle or RJDBC.
>> (I suppose adding it to DBI would mean that the one in RJDBC would
>> have to be modified.)
>>
>>
>> I have:
>>
>> Package Version
>>    "DBI" "0.3.0"
>>
>> Package Version
>> "RJDBC" "0.2-4"
>>
>>
>> Thanks
>> -Don
>>
>> --
>> Don MacQueen
>> Lawrence Livermore National Laboratory
>> 7000 East Ave., L-627
>> Livermore, CA 94550
>> 925-423-1062
>>
>
>
>
> --
> http://had.co.nz/
>
> _______________________________________________
> R-sig-DB mailing list -- R Special Interest Group R-sig-DB using r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-db
>
> _______________________________________________
> R-sig-DB mailing list -- R Special Interest Group
> R-sig-DB using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>

-- 
Peter Meißner
Workgroup 'Comparative Parliamentary Politics'
Department of Politics and Administration
University of Konstanz
Box 216
78457 Konstanz
Germany

+49 7531 88 5665
http://www.polver.uni-konstanz.de/sieberer/home/




More information about the R-sig-DB mailing list