Skip to content

Commit

Permalink
cleanup for query style and clarity. using INNER JOINS removes NULL e…
Browse files Browse the repository at this point in the history
…ntries. is this a good idea?
  • Loading branch information
dylanbeaudette committed Sep 25, 2017
1 parent 8cb1201 commit 94aa357
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions R/nasis_component_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ get_component_copm_data_from_NASIS_db <- function() {

q.copm <- "SELECT copmgrp_View_1.coiidref as coiid, copm_View_1.seqnum as seqnum, pmorder, pmdept_r, pmdepb_r, pmmodifier, pmgenmod, pmkind, pmorigin
FROM copm_View_1
RIGHT JOIN copmgrp_View_1
INNER JOIN component_View_1 on copmgrp_View_1.coiidref = component_View_1.coiid on copm_View_1.copmgrpiidref = copmgrp_View_1.copmgrpiid
FROM
component_View_1
INNER JOIN copmgrp_View_1 ON copmgrp_View_1.coiidref = component_View_1.coiid
INNER JOIN copm_View_1 ON copm_View_1.copmgrpiidref = copmgrp_View_1.copmgrpiid
ORDER BY coiidref, seqnum, pmorder, copmgrpiid ASC;"

Expand All @@ -176,13 +177,6 @@ get_component_copm_data_from_NASIS_db <- function() {
# exec query
d <- RODBC::sqlQuery(channel, q.copm, stringsAsFactors=FALSE)

# check for more than 1 record / coiid
#if(length(idx) > 0) {
# dupes <- names(idx)
# assign('multiple.otherveg.per.coiid', value=dupes, envir=soilDB.env)
# message("-> QC: multiple othervegclasses / component. Use `get('multiple.otherveg.per.coiid', envir=soilDB.env)` for related coiid values.")
#}

# close connection
RODBC::odbcClose(channel)

Expand Down

0 comments on commit 94aa357

Please sign in to comment.