 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2017-11-06 11:11:45
+-- Dump completed on 2017-11-08 16:34:12

    COMMENT 'Return multi-row result set with sample IDs, order in the group and type for sample group p_sampleGroupId'
BEGIN
    IF NOT (p_sampleGroupId IS NULL) THEN
		SELECT blSampleId "sampleId", `type` "type", groupOrder "order"
        FROM BLSampleGroup_has_BLSample 
        WHERE blSampleGroupId = p_sampleGroupId
        ORDER BY blSampleId;
    ELSE
        SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_sampleGroupId';
    END IF;

    COMMENT 'Retrieve the user friendly name and ID of all assigned instances'
BEGIN
    IF NOT (p_proposalCode IS NULL) AND NOT (p_proposalNumber IS NULL) THEN
        SELECT bls.blSampleId "sampleId", bls.containerId "containerId", bls.name "sampleName", bls.code "sampleCode", bls.comments "sampleComments", bls.location "sampleLocation",
          bls.packingFraction "samplePackingFraction", bls.dimension1 "dimension1", bls.dimension2 "dimension2", bls.dimension3 "dimension3", 
          bls.shape "shape",
          cr.crystalId "sampleTypeId", cr.name "sampleTypeName", cr.comments "sampleTypeComments", cr.spaceGroup "sampleTypeSpaceGroup",
