PL/pg SQL: improve README => add requirements

This commit is contained in:
GradedJestRisk 2019-12-22 16:43:46 +01:00
parent 06e425cc2b
commit d2588417f5
2 changed files with 21 additions and 9 deletions

View File

@ -1,9 +1,25 @@
# Requirements
You'll need:
- PostgreSQL database, version >= 11 because PROCEDURE keyword isn't supported before [version 11](https://www.postgresql.org/docs/11/release-11.html)
- OS user with local connection privilege to database on standard 5432 port
To use remote / local dockerized database, add ``` --host --port --username``` parameters to plsql invocation.
# Setup # Setup
Create database structure: psql -f ./structure/create.sql In shell:
Load code into database psql -f ./code/update_quality.sql -d gilded_rose - create database: ```createdb gilded_rose```
Load test data into database: psql -f ./test/data/load.sql -d gilded_rose - create item table (structure): ```psql -d gilded_rose -f ./structure/create.sql```
Execute: CALL update_quality(); - load code into database: ```psql -d gilded_rose -f ./code/update_quality.sql ```
Check results: SELECT * FROM items;
If you get this message```LINE 1: CREATE OR REPLACE PROCEDURE public.update_quality()```, your PostgreSQL version may under 11, consider upgrading.
# Interactive run
In shell:
- load test data into database: ```psql -d gilded_rose -f ./test/data/load.sql```
- connect to CLI: ```psql -d gilded_rose```
- check item state: ```SELECT * FROM item;```
- execute item update: ```CALL update_quality();```
- check item state: ```SELECT * FROM item;```
# Test # Test
No test code provided, only a sample of test data No test code provided, only a sample of test data

View File

@ -1,7 +1,3 @@
CREATE DATABASE gilded_rose;
\connect gilded_rose;
CREATE TABLE item ( CREATE TABLE item (
name CHARACTER VARYING(100) NOT NULL, name CHARACTER VARYING(100) NOT NULL,
sellIn INTEGER, sellIn INTEGER,