lunes, 6 de mayo de 2013

Procedimientos MySQL




mysql> create database db123;
Query OK, 1 row affected (0.23 sec)<




mysql> use db123;
Database changed
mysql> create table tmujer(id int(2) not null auto_increment primary key,nombre varchar(60) not null,tipo varchar(20) null);
Query OK, 0 rows affected (0.23 sec)







mysql> describe tmujer;





mysql> delimiter //

mysql> create procedure setmujer(in nombre varchar(60),in tipo varchar(20))

    -> begin

    -> insert into tmujer(nombre,tipo) values(nombre,tipo);

    -> select * from tmujer;
    -> end//





mysql> delimiter ;



mysql> use MySQL;
Database changed





mysql> select specific_name from proc where type='procedure';
1 row in set (0.07 sec)






mysql> select body from proc where specific_name='setmujer';
1 row in set (0.00 sec)







mysql> use db123;
Database changed






mysql> call setmujer('Pedro','Vendedor');
Query OK, 0 rows affected (0.14 sec)







mysql> call setmujer('Maria','Secretaria');
Query OK, 0 rows affected (0.06 sec)










mysql> drop procedure setmujer;

Query OK, 0 rows affected (0.40 sec)








mysql> use mysql;
Database changed






mysql> use mysql;

Database changed








mysql> select specific_name from proc;

0 rows in set (0.00 sec)









No hay comentarios:

Publicar un comentario