From 2e04933f2af776dabc3d14863e6178b1f6b40ea9 Mon Sep 17 00:00:00 2001 From: Costa <47926492N@ICO.SCS.local> Date: Tue, 19 Oct 2021 12:19:29 +0200 Subject: [PATCH] =?UTF-8?q?Creaci=C3=B3n=20sqlFunctions=20y=20de=20los=20f?= =?UTF-8?q?icheros=20de=20la=20documentaci=C3=B3n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docs/sqlFunctions-doc.Rmd | 45 ++++++ Docs/sqlFunctions-doc.html | 279 +++++++++++++++++++++++++++++++++++++ sqlFunctions.R | 7 + 3 files changed, 331 insertions(+) create mode 100644 Docs/sqlFunctions-doc.Rmd create mode 100644 Docs/sqlFunctions-doc.html create mode 100644 sqlFunctions.R diff --git a/Docs/sqlFunctions-doc.Rmd b/Docs/sqlFunctions-doc.Rmd new file mode 100644 index 0000000..a6d750c --- /dev/null +++ b/Docs/sqlFunctions-doc.Rmd @@ -0,0 +1,45 @@ +--- +title: "sqlFunctions-Doc" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + + +## sqlDropLast + +### Description +Removes from Database the last (or the amount specified) entry. + +### Usage +sqlDropLast(conn, tablename, droplast=1) + +### Arguments +Argument|Description +---|--- +conn|connection handle returned by odbcConnect. +tablename|character: a database table name accessible from the connected DSN. +droplast|the amount of lines to be removed from the table strating from tail. By default, it removes only 1 line. + +### Details +Removes from Database the last (or the amount specified) entry. + +### Value +Invisibly for success (and failures cause errors). + +### Examples +```r +dta<-odbcConnect("test") +sqlDropLast(dta, "TableTest") +``` + +### Function +```r +sqlDropLast<-function(conn, tablename, droplast=1){ + table<-sqlFetch(conn, tablename) + table<-table[1:(nrow(table)-droplast),] + sqlSave(conn, table, tablename = tablename, safer = F) +} +``` diff --git a/Docs/sqlFunctions-doc.html b/Docs/sqlFunctions-doc.html new file mode 100644 index 0000000..63ad704 --- /dev/null +++ b/Docs/sqlFunctions-doc.html @@ -0,0 +1,279 @@ + + + + +
+ + + + + + + + +Removes from Database the last (or the amount specified) entry.
+sqlDropLast(conn, tablename, droplast=1)
+Argument | +Description | +
---|---|
conn | +connection handle returned by odbcConnect. | +
tablename | +character: a database table name accessible from the connected DSN. | +
droplast | +the amount of lines to be removed from the table strating from tail. By default, it removes only 1 line. | +
Removes from Database the last (or the amount specified) entry.
+Invisibly for success (and failures cause errors).
+dta<-odbcConnect("test")
+sqlDropLast(dta, "TableTest")
+sqlDropLast<-function(conn, tablename, droplast=1){
+ table<-sqlFetch(conn, tablename)
+ table<-table[1:(nrow(table)-droplast),]
+ sqlSave(conn, table, tablename = tablename, safer = F)
+}
+