-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new sproc retrieve_grid_info_for_dc_v2
- Loading branch information
Showing
2 changed files
with
141 additions
and
0 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
66 changes: 66 additions & 0 deletions
66
schemas/ispyb/stored_programs/sp_retrieve_grid_info_for_dc_v2.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,66 @@ | ||
-- To test: | ||
-- call retrieve_grid_info_for_dc_v2(6017405, NULL); | ||
-- call retrieve_grid_info_for_dc_v2(6017405, 'boaty'); | ||
|
||
DELIMITER ;; | ||
CREATE OR REPLACE PROCEDURE `retrieve_grid_info_for_dc_v2`(IN p_dcId int unsigned, p_authLogin varchar(45)) | ||
READS SQL DATA | ||
COMMENT 'Return multi-row result-set with grid info values for the dc' | ||
BEGIN | ||
IF NOT (p_dcId IS NULL) THEN | ||
IF p_authLogin IS NOT NULL THEN | ||
SELECT | ||
gi.gridInfoId, | ||
gi.dx_mm, | ||
gi.dy_mm, | ||
gi.steps_x, | ||
gi.steps_y, | ||
gi.meshAngle, | ||
gi.micronsPerPixelX, | ||
gi.micronsPerPixelY, | ||
gi.snapshot_offsetXPixel, | ||
gi.snapshot_offsetYPixel, | ||
gi.orientation, | ||
gi.snaked | ||
FROM GridInfo gi | ||
INNER JOIN DataCollection dc ON gi.dataCollectionId = dc.dataCollectionId | ||
INNER JOIN DataCollectionGroup dcg ON dc.dataCollectionGroupId = dcg.dataCollectionGroupId | ||
INNER JOIN Session_has_Person shp ON dcg.sessionId = shp.sessionId | ||
INNER JOIN Person per ON per.personId = shp.personId | ||
WHERE per.login = p_authLogin AND gi.dataCollectionId = p_dcId | ||
GROUP BY gi.gridInfoId, | ||
gi.dx_mm, | ||
gi.dy_mm, | ||
gi.steps_x, | ||
gi.steps_y, | ||
gi.meshAngle, | ||
gi.micronsPerPixelX, | ||
gi.micronsPerPixelY, | ||
gi.snapshot_offsetXPixel, | ||
gi.snapshot_offsetYPixel, | ||
gi.orientation, | ||
gi.snaked | ||
ORDER BY gi.gridInfoId ASC; | ||
ELSE | ||
SELECT | ||
gi.gridInfoId, | ||
gi.dx_mm, | ||
gi.dy_mm, | ||
gi.steps_x, | ||
gi.steps_y, | ||
gi.meshAngle, | ||
gi.micronsPerPixelX, | ||
gi.micronsPerPixelY, | ||
gi.snapshot_offsetXPixel, | ||
gi.snapshot_offsetYPixel, | ||
gi.orientation, | ||
gi.snaked | ||
FROM GridInfo gi | ||
WHERE gi.dataCollectionId = p_dcId | ||
ORDER BY gi.gridInfoId ASC; | ||
END IF; | ||
ELSE | ||
SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument p_dcId is NULL'; | ||
END IF; | ||
END ;; | ||
DELIMITER ; |