development:sql
Differences
This shows you the differences between two versions of the page.
| development:sql [2015/02/03 14:31] – created vojtechhuser | development:sql [2015/02/03 14:35] (current) – vojtechhuser | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| CDM data can live on different databases. | CDM data can live on different databases. | ||
| - | SqlRender package provides a way to translate SQL statements across dialects. I relies on a CSV table that translates from source dialect to target dialect. | + | SqlRender package provides a way to translate SQL statements across dialects. I relies on a CSV table that translates from source dialect to target |
| - | Because of temporal issues, the source has to be MSSQLServer dialect. | ||
| - | ====== Guidelines for writing parametized | + | Another great feature of the package is ability to write SQL code that has variables. There is no "ANSI PL/ |
| - | You never know in what database you may be in, so before accessing any CDM data (e.g., person table, use the following trick | + | Eg, " |
| + | |||
| + | ====== Guidelines for writing parametized SQL code ====== | ||
| + | You never know in what database you may be in, so before accessing any CDM data (e.g., death table, use the following trick | ||
| + | select * from @cdm_database_schema.death | ||
| ===== Martijn guide ===== | ===== Martijn guide ===== | ||
| - | | + | Rename parameters of the R function using parameterized SQL from cdmSchema to cdmDatabaseSchema |
| - | Change the help for the function to indicate that for SQL Server the cdmDatabaseSchema should include ' | + | Change the help for the function to indicate that for SQL Server the cdmDatabaseSchema should include ' |
| - | Within the R function, add something like this: cdmDatabase <- strsplit(cdmDatabaseSchema ," | + | Within the R function, add something like this: cdmDatabase <- strsplit(cdmDatabaseSchema ," |
| - | In the parameterized SQL, rename the @cdm_schema parameter to @cdm_database_schema, | + | In the parameterized SQL, rename the @cdm_schema parameter to @cdm_database_schema, |
| - | In the parameterized SQL, add a parameter @cdm_database, | + | In the parameterized SQL, add a parameter @cdm_database, |
| - | Don't forget to pass the cdmDatabase parameter in R to the @cdm_database parameter in SQL when calling SqlRender. | + | Don't forget to pass the cdmDatabase parameter in R to the @cdm_database parameter in SQL when calling SqlRender. |
development/sql.1422973891.txt.gz · Last modified: by vojtechhuser
