mercredi 5 août 2020

Creating Stored Procedures by using if else statement giving compilation error

New to DB2. Version 11. While creating stored procedure it gives an error Incorrect syntax near 'FROM' expected: BULKINFO

CREATE PROCEDURE My_StrProc 
( IN @rollNumber     Varchar(18), 
  IN @studentType       Varchar(3),   
 OUT @studentID        Varchar(15),   
 OUT @oldStudentType   Varchar(4) ,  
 OUT  @oldBranch Varchar(3) ,  
 OUT @newStudentType    Varchar(4) ,  
 OUT @newBranch Varchar(4) 
)
BEGIN
IF @studentType IS NOT NULL 
    THEN
    Select  
            @studentID       =  REGISTRATION_NO,  
            @oldStudentType   = OLD_STUD_TYPE,  
            @oldBranch    = OLD_BRANCH,  
            @newStudentType    = NEW_STUD_TYPE,  
            @newBranch = NEW_BRANCH
        From  
            Migrated_Student  
        Where  
            OLD_STUDENT_NUM = @rollNumber and   
            ACTIVE = 'P';
ELSE
    Select  
            @studentID       = REGISTRATIONNO,  
            @oldStudentType   = OLD_STUD_TYPE,  
            @oldBranch    = OLD_BRANCH,  
            @newStudentType   = NEW_STUD_TYPE,  
            @newBranch    = NEW_BRANCH
                    From  
            Migrated_Student  
        Where  
            OLD_STUDENT _NUM = @rollNumber and  
            OLD_ STUDENT _TYPE = @studentType and  
            ACTIVE = 'P';
END IF;
END;

Aucun commentaire:

Enregistrer un commentaire