Scripts relacionados con el acceso y análisis en bases de datos Access.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
986 B

  1. ---
  2. title: "sqlFunctions-Doc"
  3. output: html_document
  4. ---
  5. ```{r setup, include=FALSE}
  6. knitr::opts_chunk$set(echo = TRUE)
  7. ```
  8. ## sqlDropLast
  9. ### Description
  10. Removes from Database the last (or the amount specified) entry.
  11. ### Usage
  12. sqlDropLast(conn, tablename, droplast=1)
  13. ### Arguments
  14. Argument|Description
  15. ---|---
  16. conn|connection handle returned by odbcConnect.
  17. tablename|character: a database table name accessible from the connected DSN.
  18. droplast|the amount of lines to be removed from the table strating from tail. By default, it removes only 1 line.
  19. ### Details
  20. Removes from Database the last (or the amount specified) entry.
  21. ### Value
  22. Invisibly for success (and failures cause errors).
  23. ### Examples
  24. ```r
  25. dta<-odbcConnect("test")
  26. sqlDropLast(dta, "TableTest")
  27. ```
  28. ### Function
  29. ```r
  30. sqlDropLast<-function(conn, tablename, droplast=1){
  31. table<-sqlFetch(conn, tablename)
  32. table<-table[1:(nrow(table)-droplast),]
  33. sqlSave(conn, table, tablename = tablename, safer = F)
  34. }
  35. ```