Compare commits

...

2 Commits
main ... vbn-rt

3 changed files with 13 additions and 1 deletions

View File

@ -36,6 +36,8 @@ psql -h localhost -p 5432 -U $DB_USER -f ./sql/rts-stps-trps-cnt.sql -d $DB_NAME
#
psql -h localhost -p 5432 -U $DB_USER -f ./sql/join-gncy-rts-trps-srvcs.sql -d $DB_NAME -v schema=$DB_SCHEMA
#
psql -h localhost -p 5432 -U $DB_USER -f ./sql/join-gncy-rts-trps-srvcs-vbn-rt.sql -d $DB_NAME -v schema=$DB_SCHEMA
#
psql -h localhost -p 5432 -U $DB_USER -f ./sql/trip-updates.sql -d $DB_NAME -v schema=$DB_SCHEMA
#
psql -h localhost -p 5432 -U $DB_USER -f ./sql/join-gncy-rts-trps-srvcs-pdts.sql -d $DB_NAME -v schema=$DB_SCHEMA

View File

@ -5,4 +5,5 @@ SET search_path to :schema, public;
---create view
DROP VIEW IF EXISTS :schema.vw_join_gncy_rts_trps_srvcs_pdts CASCADE;
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_srvcs_pdts AS SELECT srvcs.agency_name, srvcs.agency_id, srvcs.route_id, srvcs.route_short_name, srvcs.service_id, srvcs.trip_id, srvcs.trip_short_name, srvcs.trip_headsign, srvcs.dates, pdts.timestamp_pgsql FROM :schema.vw_join_gncy_rts_trps_srvcs AS srvcs LEFT JOIN :schema.trip_updates AS pdts ON srvcs.route_id = pdts.trip_route_id AND srvcs.trip_id = pdts.trip_trip_id ORDER BY srvcs.agency_name, srvcs.route_id, srvcs.trip_id, pdts.timestamp_pgsql;
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_srvcs_pdts
AS SELECT srvcs.agency_name, srvcs.agency_id, srvcs.route_id, srvcs.route_short_name, srvcs.service_id, srvcs.trip_id, srvcs.trip_short_name, srvcs.trip_headsign, srvcs.dates, pdts.timestamp_pgsql FROM :schema.vw_join_gncy_rts_trps_srvcs_vbn_rt AS srvcs LEFT JOIN :schema.trip_updates AS pdts ON srvcs.route_id = pdts.trip_route_id AND srvcs.trip_id = pdts.trip_trip_id ORDER BY srvcs.agency_name, srvcs.route_id, srvcs.trip_id, pdts.timestamp_pgsql;

View File

@ -0,0 +1,9 @@
-- colon before variable: for a prepared statement using named placeholders, this will be a parameter name of the form :name
CREATE SCHEMA IF NOT EXISTS :schema;
SET search_path to :schema, public;
---create view
DROP VIEW IF EXISTS :schema.vw_join_gncy_rts_trps_srvcs_vbn_rt CASCADE;
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_srvcs_vbn_rt
AS SELECT trps.agency_id, trps.agency_name, trps.route_id, trps.route_short_name, trps.service_id, trps.trip_id, trps.trip_short_name, trps.trip_headsign, srvcs.dates FROM :schema.vw_join_gncy_rts_trps AS trps LEFT JOIN :schema.services AS srvcs ON trps.service_id = srvcs.service_id WHERE trps.agency_id != '123' AND trps.agency_id != '1542' AND trps.agency_id != '552' AND trps.agency_id != '553' AND trps.agency_id != '271' ORDER BY trps.agency_name, trps.route_id, trps.trip_id;