E
E
Ekaterina Shundeeva2020-09-16 19:46:13
SQL
Ekaterina Shundeeva, 2020-09-16 19:46:13

How to add input validation to a stored procedure?

Good day. I have such a problem. There is a task: To develop stored procedures for adding/changing/deleting data. It is necessary to add checks of input data to the procedures according to the table above. (data type, NOT NULL condition, data uniqueness) If incorrect data is entered, output text with a readable error.

There is a code with a procedure:

CREATE PROCEDURE add_product (a INT, b TIMESTAMP, c VARCHAR(20), d VARCHAR(50), e INT, f INT)
LANGUAGE SQL
AS $$
INSERT INTO sales (ID, Sale_time, Pharmacy, product, Number_of_packages, Price)
VALUES (a, b, c, d, e, f);
$$;

How to add input validation to this procedure? Thank you in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan., 2020-09-16
@LaRN

Judging by the code you have MySql.
Here are the details:
https://www.w3resource.com/mysql/mysql-procedure.php
And here is a small example:
https://www.tutorialspoint.com/how-to-display-mess...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question