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 @@ + + + + + + + + + + + + + +sqlFunctions-Doc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+

sqlDropLast

+
+

Description

+

Removes from Database the last (or the amount specified) entry.

+
+
+

Usage

+

sqlDropLast(conn, tablename, droplast=1)

+
+
+

Arguments

+ ++++ + + + + + + + + + + + + + + + + + + + + +
ArgumentDescription
connconnection handle returned by odbcConnect.
tablenamecharacter: a database table name accessible from the connected DSN.
droplastthe 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

+
dta<-odbcConnect("test")
+sqlDropLast(dta, "TableTest")
+
+
+

Function

+
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/sqlFunctions.R b/sqlFunctions.R new file mode 100644 index 0000000..a1f35d4 --- /dev/null +++ b/sqlFunctions.R @@ -0,0 +1,7 @@ +require(RODBC) + +sqlDropLast<-function(conn, tablename, droplast=1){ + table<-sqlFetch(conn, tablename) + table<-table[1:(nrow(table)-droplast),] + sqlSave(conn, table, tablename = tablename, safer = F) +}