preparation

Table info.

Title Preparation
Description Preparation

Fields

Name Type Required Index Hidden On form Title Pick list Description
PreparationID int(11) PRI
TimestampCreated datetime Created The timestamp the record was created.
TimestampModified datetime Last edited The timestamp the record was last modified.
Version int(11) Version version
CollectionMemberID int(11) MUL Collection Member Id collectionMemberId
CountAmt int(11) Quantity The number of items belonging to a preparation type
Description varchar(255) Orig. herb. The Index Herbariorum code of the institution the actual specimen is held at, where we have received a photograph or cibachrome of the specimen from a different herbarium
Number1 float(20,10) Number1
Number2 float(20,10) Number2 number2
PreparedDate date MUL Prepared date preparedDate
PreparedDatePrecision tinyint(4) Prepared Date Precision preparedDatePrecision
Remarks text Multisheets Information about multisheet relationships
SampleNumber varchar(32) MUL Number The number assigned to the spirit jar, microscope slide or silica gel sample, or the Library reference number for a colour transparency
Status varchar(32) status
StorageLocation varchar(50) storageLocation
Text1 text MEL duplicates at The herbarium that a duplicate of a MEL specimen was sent to
Text2 text Other dupl. at The Index Herbariorum codes of the herbaria that also hold duplicates of specimens sent to MEL as exchange or donations
YesNo1 bit(1) Hort. Ref. Set To indicate that a specimen is in the Horticultural Reference Set.
YesNo2 bit(1) Yes No2 yesNo2
YesNo3 bit(1) Yes No3 yesNo3
CreatedByAgentID int(11) MUL
StorageID int(11) MUL
CollectionObjectID int(11) MUL
PreparedByID int(11) MUL
PrepTypeID int(11) MUL
ModifiedByAgentID int(11) MUL
PreparationAttributeID int(11) MUL
Integer1 int(11) Jar size JarSize
  • A
  • B
  • C
  • D
The spirit jar size
Integer2 int(11) Integer2 integer2
ReservedInteger3 int(11) Reserved Integer3 reservedInteger3
ReservedInteger4 int(11) Reserved Integer4 reservedInteger4
GUID varchar(128) UNI Guid guid
Text3 text Text3 text3
Text4 text Text4 text4
Text5 text Text5 text5
Date1 date Date1 date1
Date1Precision tinyint(4) Date1 Precision date1Precision
Date2 date Date2 date2
Date2Precision tinyint(4) Date2 Precision date2Precision
Date3 date Date3 date3
Date3Precision tinyint(4) Date3 Precision date3Precision
Date4 date Date4 date4
Date4Precision tinyint(4) Date4 Precision date4Precision
Text6 text Text6 text6
Text7 text Text7 text7
Text8 text Text8 text8
Text9 text Text9 text9
AlternateStorageID int(11) MUL
BarCode varchar(256) Bar Code Bar Code

Indexes

Name Fields Unique Nullable
FKB198269745F8D1A8 PreparationAttributeID
FKB19826975327F942 ModifiedByAgentID
FKB19826976E8973EC PrepTypeID
FKB198269775E37458 CollectionObjectID
FKB19826977699B003 CreatedByAgentID
FKB1982697EB48144E StorageID
FKB1982697EBDCBD14 AlternateStorageID
FKB1982697FEE420B1 PreparedByID
PreparedDateIDX PreparedDate
PrepColMemIDX CollectionMemberID
PrepGuidIDX GUID
PrepSampleNumIDX SampleNumber
PRIMARY PreparationID

One-to-many relationships

Name Field Related table Related field
FKC040F46418627F06 PreparationID conservdescription PreparationID
FK6A06F1F418627F06 PreparationID deaccessionpreparation PreparationID
FK9A0BCB518627F06 PreparationID exchangeinprep PreparationID
FK7405CEF818627F06 PreparationID exchangeoutprep PreparationID
FK18B1F6718627F06 PreparationID giftpreparation PreparationID
FK374DEBA718627F06 PreparationID loanpreparation PreparationID
FKD5CE219118627F06 PreparationID materialsample PreparationID
FKE3FD6EFA18627F06 PreparationID preparationattachment PreparationID
FK4592DD0818627F06 PreparationID preparationattr PreparationId
FKFB3D7D6C18627F06 PreparationID preparationproperty PreparationID

Many-to-one relationships

Name Field Related table Related field
FKB198269745F8D1A8 PreparationAttributeID preparationattribute PreparationAttributeID
FKB19826975327F942 ModifiedByAgentID agent AgentID
FKB19826976E8973EC PrepTypeID preptype PrepTypeID
FKB198269775E37458 CollectionObjectID collectionobject CollectionObjectID
FKB19826977699B003 CreatedByAgentID agent AgentID
FKB1982697EB48144E StorageID storage StorageID
FKB1982697EBDCBD14 AlternateStorageID storage StorageID
FKB1982697FEE420B1 PreparedByID agent AgentID

preparation_before_insert

EventINSERT
TimingBEFORE
Statement:
DROP TRIGGER IF EXISTS preparation_before_insert;
 
DELIMITER $$
 
CREATE TRIGGER preparation_before_insert BEFORE INSERT ON preparation
FOR EACH ROW
  BEGIN
    DECLARE new_number VARCHAR(32);
    IF isnull(@DISABLE_TRIGGER) THEN
      IF NEW.PrepTypeID=2 THEN 
        IF NEW.SampleNumber IS NULL THEN
            SELECT MAX(CAST(SampleNumber AS UNSIGNED))+1
            INTO new_number
            FROM preparation
            WHERE PrepTypeID=2;
        ELSE
            SET new_number=NEW.SampleNumber;
        END IF;
 
      ELSEIF NEW.PrepTypeID=6 THEN 
        IF NEW.SampleNumber IS NULL THEN
            SELECT MAX(CAST(SampleNumber AS UNSIGNED))+1
            INTO new_number
            FROM preparation
            WHERE PrepTypeID=6;
        ELSE
            SET new_number=NEW.SampleNumber;
        END IF;
 
      ELSEIF NEW.PrepTypeID=7 THEN  
        SELECT MAX(CAST(SampleNumber AS UNSIGNED))+1
        INTO new_number
        FROM preparation
        WHERE PrepTypeID=7;
 
      ELSEIF NEW.PrepTypeID=18 THEN 
        SELECT IF(MAX(SampleNumber) IS NOT NULL, MAX(SampleNumber)+1, 1)
        INTO new_number
        FROM preparation
        WHERE PrepTypeID=18;
 
        SET new_number=LPAD(new_number, 6, '0');
 
      ELSEIF NEW.PrepTypeID=14 THEN 
        SELECT IF(MAX(SampleNumber) IS NOT NULL, MAX(SampleNumber)+1, 1)
        INTO new_number
        FROM preparation
        WHERE PrepTypeID=14;
 
        SELECT IF(MAX(CatalogNumber)>new_number, MAX(CatalogNumber)+1, new_number)
        INTO new_number
        FROM collectionobject
        WHERE CollectionID=294912;
 
        SET new_number=lpad(new_number, 7, '0');
 
      ELSEIF NEW.PrepTypeID=155 THEN 
        SELECT IF(MAX(SampleNumber) IS NOT NULL, MAX(CAST(SampleNumber AS UNSIGNED))+1, 1)
        INTO new_number
        FROM preparation
        WHERE PrepTypeID=155;
 
      ELSE
        SET new_number=NEW.SampleNumber;
 
      END IF;
 
      SET NEW.SampleNumber=new_number;
 
    END IF;
  END
 
DELIMITER ;

preparation_before_update

EventUPDATE
TimingBEFORE
Statement:
DROP TRIGGER IF EXISTS preparation_before_update;
 
DELIMITER $$
 
CREATE TRIGGER preparation_before_update BEFORE UPDATE ON preparation
FOR EACH ROW
  BEGIN
    DECLARE new_number VARCHAR(32);
 
    IF isnull(@DISABLE_TRIGGER) THEN
      IF NEW.PrepTypeID=18 AND OLD.PrepTypeID=24 AND NEW.SampleNumber IS NULL AND OLD.SampleNumber IS NULL THEN 
        IF NEW.SampleNumber IS NULL THEN
          SELECT IF(MAX(SampleNumber) IS NOT NULL, MAX(SampleNumber)+1, 1)
          INTO new_number
          FROM preparation
          WHERE PrepTypeID=18;
 
          SET NEW.SampleNumber = LPAD(new_number, 6, '0');
        END IF;
      END IF;
    END IF;
  END
 
DELIMITER ;