Joseph Joseph - 4 years ago 97
MySQL Question

Using parameters for stored procedures on MySQL

I'm trying to write a PL/SQL or T-SQL for the following example:

Write a PL/SQL or T-SQL procedure to retrieve and output the marina number, slip number, rental fee, boat name, and owner number for every slip whose length is equal to the length stored in

I_LENGTH
.

So far I've come up with this:


'Create Procedure Boat_Info (I_Length IN Marina_Slip.Length%Type) AS
I_Marina_Num Marina_Slip.Marina_Num%Type I_Slip_Num

Marina_Slip.Slip_Num%Type I_Rental_Fee Marina_Slip.Rental_Fee%Type
I_Boat_Name Marina_Slip.Boat_Name%Type I_Owner_Num

Marina_Slip.Owner_Num%Type;

Begin Select Marina_Num, Slip_Num, Rental_Fee, Boat_Name, Owner_Num
Into I_Marina_Num, I_Slip_Num, I_Rental_Fee, I_Boat_Name, I_Owner_Num
from Marina_Slip Where Length = ??


That last part I'm still missing, as I'm have no specific value for Length to restrict my output. and also cannot come up with a DBMS output.

Answer Source

The variable in paranthesis is a parameter. Yo can use it in your where clause. For example :

(myLenght INT)

where length = myLength

You may define more than one parameters separated by a comma sign ,

See also: Mysql stored procedure parameters

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download