Skip to content

[FORMATTING] It does not work well whenever defining procedure and chand changing the delimiter #827

@aryanthepain

Description

@aryanthepain

Input data

Which SQL and options did you provide as input?

DELIMITER //

CREATE PROCEDURE register_student(
    IN student_name VARCHAR(25),
    IN student_photo BLOB,
    IN student_phone INT(10),
    IN student_password VARCHAR(20)
)
BEGIN
    DECLARE new_roll_number BIGINT;
    
    -- Insert student details
    INSERT INTO students (name, photo, Phone_no)
    VALUES (student_name, student_photo, student_phone);

    -- Get the last inserted Roll_number
    SET new_roll_number = LAST_INSERT_ID();

    -- Insert password entry
    INSERT INTO student_password (Roll_number, password)
    VALUES (new_roll_number, student_password);
    
END;
//

DELIMITER ;

Expected Output

DELIMITER //

CREATE PROCEDURE register_student(
    IN student_name VARCHAR(25),
    IN student_photo BLOB,
    IN student_phone INT(10),
    IN student_password VARCHAR(20)
)
BEGIN
    DECLARE new_roll_number BIGINT;
    
    -- Insert student details
    INSERT INTO students (name, photo, Phone_no)
    VALUES (student_name, student_photo, student_phone);

    -- Get the last inserted Roll_number
    SET new_roll_number = LAST_INSERT_ID();

    -- Insert password entry
    INSERT INTO student_password (Roll_number, password)
    VALUES (new_roll_number, student_password);
    
END;
//

DELIMITER ;

Actual Output

DELIMITER / / CREATE PROCEDURE register_student (
    IN student_name VARCHAR(25),
    IN student_photo BLOB,
    IN student_phone INT (10),
    IN student_password VARCHAR(20)
) BEGIN DECLARE new_roll_number BIGINT;

-- Insert student details
INSERT INTO
    students (name, photo, Phone_no)
VALUES
    (student_name, student_photo, student_phone);

-- Get the last inserted Roll_number
SET
    new_roll_number = LAST_INSERT_ID ();

-- Insert password entry
INSERT INTO
    student_password (Roll_number, password)
VALUES
    (new_roll_number, student_password);

END;

/ / DELIMITER;

Usage

  • How are you calling / using the library?
    in vscode
  • What SQL language(s) does this apply to?
    mysqlite
  • Which SQL Formatter version are you using?
    1.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions