-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from DiamondLightSource/SCI-8592
New SP retrieve_sessions_for_beamline_and_run
- Loading branch information
Showing
2 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
schema/stored_programs/sp_retrieve_sessions_for_beamline_and_run.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DELIMITER ;; | ||
CREATE OR REPLACE DEFINER=`ispyb_root`@`%` PROCEDURE `retrieve_sessions_for_beamline_and_run`( | ||
IN p_beamline varchar(15), | ||
IN p_run varchar(7) | ||
) | ||
READS SQL DATA | ||
COMMENT 'Returns a multi-row result-set with the sessions (mx12345-123), their start and end dates for beamline p_beamline and run p_run' | ||
BEGIN | ||
SELECT | ||
bs.sessionId "sessionId", | ||
concat(p.proposalCode, p.proposalNumber, '-', bs.visit_number) "session", | ||
bs.startDate "startDate", | ||
bs.endDate "endDate" | ||
FROM Proposal p | ||
INNER JOIN BLSession bs on p.proposalId = bs.proposalId | ||
INNER JOIN v_run vr ON bs.startDate BETWEEN vr.startDate AND vr.endDate | ||
WHERE bs.beamlinename = p_beamline AND vr.run = p_run | ||
ORDER BY bs.startDate, bs.sessionId; | ||
END;; | ||
|
||
DELIMITER ; |