You should understand that phpMyAdmin doesn’t use Packages, as it could be realized in Oracle. All of the functions and procedures will be in a bundle, hence it’d be useful to apply some special prefix in the Routine name field.
The simplest way to create one you can see below. You need to know:
- The name of your Function/Procedure
- How many input parameters have you defined
- Their data types
- What do you need as output
- You can define what you need to create. It would a function or a procedure. Let’s create a :
- Now you can see window below:
- Give it Routine name and define Type:
- Add as many input parameters as you wish. Give them names, data types, in case of INTEGER default values, in case of VARCHAR length, and Options :
Also, a Direction (IN / OUT) need to be defined during Procedure creating. Remember, that a Procedure doesn’t require Output parameters, as it does in case of Function. It’s optional.
- Define output parameter, its data type and/or length/values:
- Here should be SQL code or any other workable stuff. Start it with keyword BEGIN and close it with the other one END:
- At the end need to be defined Definer. For example, it could be like `dbprefix`
@`localhost` and SQL data access.
- The final view of a simple complete Function looks like below:
- If you wanna use some Procedure(-s) inside of your Function, then you may need to use next construction. Here y1, y2 are Input parameters and a is an Output parameter, which you can use in further.