aboutsummaryrefslogtreecommitdiffstats
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/load_cf.R25
1 files changed, 11 insertions, 14 deletions
diff --git a/R/load_cf.R b/R/load_cf.R
index b29e7646..1110b97d 100644
--- a/R/load_cf.R
+++ b/R/load_cf.R
@@ -328,13 +328,12 @@ save(cusipdata, cfdata, file=file.path(save.dir, "cashflows.RData"),
sqlstring <- paste0("UPDATE et_deal_model_numbers SET ",
"wapbasis = $1 WHERE dealname= $2 AND updatedate = $3")
for(dealname in names(cfdata)){
- r <- tryCatch(dbSendQuery(etdb, sqlstring, params = list(cfdata[[dealname]]$wapbasis*100,
- dealname,
- tradedate)),
- error = function(w) {
- logerror(w$message)
- })
- dbClearResult(r)
+ tryCatch(dbGetQuery(etdb, sqlstring, params = list(cfdata[[dealname]]$wapbasis*100,
+ dealname,
+ tradedate)),
+ error = function(w) {
+ logerror(w$message)
+ })
}
## upload model data
@@ -357,12 +356,11 @@ for(cusip in names(cusipdata)){
paste(names(params), collapse=","),
paste(paste0("$", 1:length(params)), collapse=","))
}
- r <- tryCatch(dbSendQuery(etdb, sqlstring, params=params),
- error = function(w) cat(w$message))
- dbClearResult(r)
+ tryCatch(dbGetQuery(etdb, sqlstring, params=params),
+ error = function(e) logerror(e$message))
identifier <- tryCatch(dbGetQuery(dawndb, "SELECT identifier from securities WHERE cusip=$1",
params=list(cusip)),
- error = function(w) logerror(w$message))
+ error = function(e) logerror(e$message))
identifier <- if(nrow(identifier)>0) identifier$identifier else NULL
if(!is.null(identifier)){
if(nrow(sqldata) && (tradedate %in% as.Date(sqldata$updatedate))){
@@ -376,9 +374,8 @@ for(cusip in names(cusipdata)){
params <- c(identifier, as.character(tradedate), 'HY', values[1:4])
}
- r <- tryCatch(dbSendQuery(dawndb, sqlstring, params=params),
- error = function(w) logerror(w$message))
- dbClearResult(r)
+ tryCatch(dbGetQuery(dawndb, sqlstring, params=params),
+ error = function(w) logerror(w$message))
}
}
dbDisconnect(dawndb)