/*
MySQL Data Transfer
Source Host: localhost
Source Database: usuario
Target Host: localhost
Target Database: usuario
Date: 21/02/2008 09:39:16 a.m.
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for usuarios
-- ----------------------------
CREATE TABLE `usuarios` (
  `nombre` varchar(32) default NULL,
  `apaterno` varchar(23) default NULL,
  `amaterno` varchar(32) default NULL,
  `id` int(23) NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- ----------------------------
-- Procedure structure for getdelete
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `getdelete`(IN pfolio INT)
BEGIN
delete from regproblema where folio=pfolio;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for getinsert
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `getinsert`(IN problema VARCHAR(25),IN Area VARCHAR(25),IN perreg VARCHAR(25),IN causa VARCHAR(25),IN descripcion VARCHAR(25),IN fecha DATE,OUT pfolio INT)
BEGIN
insert into regproblema(problema,Area,personaqueregistra,causa,descripcion,fecha)
values (problema,Area,perreg,causa,descripcion,fecha);
set pfolio=@@IDENTITY;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for getIuse
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `getIuse`(
IN usuario VARCHAR(25),
IN psw VARCHAR(25),
IN nombre VARCHAR(10),
IN apellido VARCHAR(10),
OUT pid INT
)
BEGIN
insert into user(usuario,psw,nombre,apellido)
values(usuario,psw,nombre,apellido);
set pid=@@IDENTITY;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for getupPbl
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `getupPbl`(
IN problema VARCHAR(25),
IN Area VARCHAR(25),
IN causa VARCHAR(25),
IN descripcion VARCHAR(25),
IN pfolio INT
)
BEGIN
update regproblema set problema=problema,Area=Area,causa=causa,descripcion=descripcion where folio=pfolio;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for insert
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `insert`(IN vp varchar(25),IN va varchar(25),IN vper varchar(25),vc varchar(50),vd varchar(50),out pfolio INT)
BEGIN
insert into regproblema(problema,Area,personaqueregistra,causa,descripcion)
values(vp,va,vper,vc,d);
SET pfolio=@@IDENTITY;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for insertregproblema
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `insertregproblema`(
IN vproblema varchar(25),
IN vArea varchar(25),
OUT Pfolio INT
)
BEGIN
insert into regproblem(problema,Area)
values (vproblema,vArea);
set Pfolio=@@IDENTITY;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for session
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `session`(IN vusuario CHAR(20),IN vpassword CHAR(20),OUT permitir BOOL,OUT outid INT)
BEGIN
SELECT  COUNT(*) INTO permitir  FROM usuarios where usuario=vusuario and password=vpassword;
SELECT id INTO outid from usuarios where usuario=vusuario and password=vpassword;
END;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for verusuarios
-- ----------------------------
DELIMITER ;;
CREATE PROCEDURE `verusuarios`()
BEGIN
select * from user;
END;;
DELIMITER ;

-- ----------------------------
-- Records 
-- ----------------------------
INSERT INTO `usuarios` VALUES ('Miza', '', 'Julio', '6');
INSERT INTO `usuarios` VALUES ('Bruno', 'Espinosa', 'Cas', '11');
INSERT INTO `usuarios` VALUES ('Brj', 'drj', 'jr', '12');
