Browse Source

Solucionar otro problema de duplicado.

main
del Carpio Huerta 2 years ago
parent
commit
34b54230cb
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      sqlFunctions.R

+ 4
- 4
sqlFunctions.R

@ -73,7 +73,7 @@ sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
dbid<-sqlFetch(conn,db["dbcode"]) dbid<-sqlFetch(conn,db["dbcode"])
new.nhc<-nhcs[!nhcs %in% dbid$NHC]
new.nhc<-nhcs[!nhcs %in% dbid$NHC] %>% unique()
if(length(new.nhc) > 0){ if(length(new.nhc) > 0){
next.num<-gsub(db["dbcode"],"",dbid[,db["dbcode"]]) %>% as.numeric %>% max(na.rm=T)+1 next.num<-gsub(db["dbcode"],"",dbid[,db["dbcode"]]) %>% as.numeric %>% max(na.rm=T)+1
last.num<-next.num+(length(new.nhc)-1) last.num<-next.num+(length(new.nhc)-1)
@ -82,8 +82,8 @@ sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
dbid<-rbind(dbid,newtab) dbid<-rbind(dbid,newtab)
} }
if(dbtype=="UM"){ if(dbtype=="UM"){
dbid<-merge(dbid, newtab, all=T) %>% select(Id,NHC,UMID) %>% arrange(Id)
dbid$Id<-as.numeric(rownames(dbid))
dbid<-merge(dbid, newtab, all=T) %>% select(NHC,UMID) %>% arrange(UMID)
# dbid$Id<-as.numeric(rownames(dbid))
dbid$NHC<-as.numeric(dbid$NHC) dbid$NHC<-as.numeric(dbid$NHC)
} }
rownames(dbid)<-as.character(1:nrow(dbid)) rownames(dbid)<-as.character(1:nrow(dbid))
@ -91,7 +91,7 @@ sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
if (sinc){ if (sinc){
### !! Atención, esto cambia la base de datos: ### !! Atención, esto cambia la base de datos:
sqlSave(conn, dbid, tablename=db["dbcode"], append = T)
sqlSave(conn, dbid, tablename=db["dbcode"], append = T, rownames = F)
print("La base ha sido actualizada.") print("La base ha sido actualizada.")
} }
if (verb){ if (verb){

Loading…
Cancel
Save