Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/07/2009, 13:51
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
Puntos: 8
Auditoría MySQL

Estoy usando el MySQL 5.1.34. He creado una base de datos y tablas como muestra el código abajo.

Código:
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 03-07-2009 a las 20:43:33
-- Versión del servidor: 5.1.34
-- Versión de PHP: 5.2.10

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Base de datos: `prueba01`
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos`
--

CREATE TABLE IF NOT EXISTS `datos` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `RELE_1` tinyint(4) NOT NULL,
  `RELE_2` tinyint(4) NOT NULL,
  `RELE_3` tinyint(4) NOT NULL,
  `RELE_4` tinyint(4) NOT NULL,
  `FECHA_HORA` datetime NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci AUTO_INCREMENT=3 ;

--
-- Volcar la base de datos para la tabla `datos`
--

INSERT INTO `datos` (`ID`, `RELE_1`, `RELE_2`, `RELE_3`, `RELE_4`, `FECHA_HORA`) VALUES
(1, 1, 0, 1, 0, '2009-07-03 15:01:37'),
(2, 1, 0, 1, 1, '2009-07-03 15:21:48');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `dispositivos`
--

CREATE TABLE IF NOT EXISTS `dispositivos` (
  `ID` int(11) NOT NULL,
  `nombre` varchar(30) NOT NULL,
  `estado` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `descripcion` varchar(200) NOT NULL,
  PRIMARY KEY (`ID`),
  FULLTEXT KEY `nombre` (`nombre`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Volcar la base de datos para la tabla `dispositivos`
--

INSERT INTO `dispositivos` (`ID`, `nombre`, `estado`, `descripcion`) VALUES
(1, 'RELE 1', 0, 'Motor 1'),
(2, 'RELE 2', 0, 'Motor 2'),
(3, 'RELE 3', 0, 'Alarma'),
(4, 'RELE 4', 0, 'WebCam');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `tabla01`
--

CREATE TABLE IF NOT EXISTS `tabla01` (
  `RELE_1` tinyint(1) DEFAULT NULL,
  `RELE_2` tinyint(1) DEFAULT NULL,
  `RELE_3` tinyint(1) DEFAULT NULL,
  `RELE_4` tinyint(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

--
-- Volcar la base de datos para la tabla `tabla01`
--

INSERT INTO `tabla01` (`RELE_1`, `RELE_2`, `RELE_3`, `RELE_4`) VALUES
(1, 1, 0, 0);



Quiero aplicar este código en phpmyadmin o cual sea, este código que me da error.

Código:
CREATE TRIGGER datos AFTER UPDATE ON dispositivos 
   FOR EACH ROW
   BEGIN
   INSERT INTO datos(nombre, estado, descripcion)
   VALUES (NEW.rele_1, NEW.rele_2, NEW.rele_3, NEW.rele_4, NOW() );
   END;
Concretamente me da error en esta línea.
Código:
   VALUES (NEW.rele_1, NEW.rele_2, NEW.rele_3, NEW.rele_4, NOW() );
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar