Page 125 - Computer Software Application TP - Volume 1
P. 125

COMPUTER SOFTWARE APPLICATION - CITS



           EXERCISE 34 : Using Cursors in MySQL


            Objectives

            At the end of this exercise you shall be able to
           •  create a stored procedure with cursor
           •  use the cursors in MySQL

           Requirements

           Tools/Materials
           •   Desktop/Laptop with latest configuration
           •   Operating system: window 10:11
           •  XAMPP server r3.3.0


           Procedure


           TASK 1 : Using a cursor in MySQL
           1  OPEN MYSQL COMMAND LINE –
           Open the MySQL Command Line or any MySQL client that allows you to execute SQL commands.
           2  CONNECT YOUR DATABASE –

           mysql -u your username –p
           Enter your password when prompted.
           3  SELECT YOUR DATABASE –
           USE your database name;
           Replace your database name with the name of your actual database.












           4  Create a table –

           Let’s create a simple table for this example:
           CREATE TABLE employee (
               emp id INT PRIMARY KEY AUTO INCREMENT,
               emp name VARCHAR(255),

               emp salary DECIMAL(10, 2)
           );













                                                           110
   120   121   122   123   124   125   126   127   128   129   130