Skip to content

Commit

Permalink
Merge pull request #11 from equella/issue/10
Browse files Browse the repository at this point in the history
#10:  Add how to name parameters in Postgres

Invoking 'lazy consensus'.  Please open another PR if needed.
  • Loading branch information
cbeach47 committed Dec 22, 2018
2 parents b412ffc + 242b2f2 commit dc79b8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions tutorials/reporting/README.md
Expand Up @@ -41,6 +41,7 @@ these tutorials.
Postgres:
1. [Querying with the native XML type](postgres/QueryingXMLType.md)
1. [Querying repeated metadata](postgres/RepeatedMetadata.md)
1. [Querying with named parameters](postgres/NamingParameters.md)

SQLServer:
1. [Querying with the native XML type](sqlserver/QueryingXMLType.md)
Expand Down
15 changes: 15 additions & 0 deletions tutorials/reporting/postgres/NamingParameters.md
@@ -0,0 +1,15 @@
## Naming Parameters

There are times when using the question mark syntax for bringing in parameters is not the best choice - a parameter might need to be used in multiple places, the number of parameters could make for a confusing SQL query, etc. After setting up the Report and Data Set parameters appropriately, use the following SQL example as a guide to 'name' the parameters directly in the query.

```sql
with vars as (
select
?::date as startdate,
?::date as enddate
)
select uuid, version, date_created from item
where
date_created >= (select startdate from vars) and
date_created <= (select enddate from vars)
```

0 comments on commit dc79b8a

Please sign in to comment.