나는이 작업을 수행하는 트리거 만들고 싶어 :MYSQL 트리거 문제
UPDATE formulario
SET ano = EXTRACT(year FROM create_date),
mes = EXTRACT(month FROM create_date)
을하지만 난 그것을 만드는 문제를 많이 얻고있다. 그것은 허용되지만 작동하지 않거나 새로운 행을 게시 할 때 오류 메시지를 표시합니다. create_date
을 삽입하고 ano
및 mes
을 자동으로 장착하고 싶습니다. 내가 어떻게 할 수 있니?
-- Dumping structure for table at.formulario
CREATE TABLE IF NOT EXISTS `formulario` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`uniqid` varchar(38) DEFAULT NULL,
`create_date` date DEFAULT NULL,
`ano` int(4) DEFAULT NULL,
`mes` int(2) DEFAULT NULL,
`codcliente` int(8) DEFAULT NULL,
`tipo_act` int(1) DEFAULT NULL,
`contacto_nome` varchar(50) DEFAULT NULL,
`contacto_funcao` int(1) DEFAULT NULL,
`contacto_telefone` varchar(20) DEFAULT NULL,
`cara_cli_abc` int(1) DEFAULT NULL,
`cara_cli_estado` int(1) DEFAULT NULL,
`cara_cli_tipo_est` int(3) DEFAULT NULL,
`cara_cli_sazonal` int(1) DEFAULT '0',
`loc_inst_piso` varchar(5) DEFAULT NULL,
`loc_inst_acesso` int(1) DEFAULT NULL,
`loc_inst_data_vistoria` date DEFAULT NULL,
`loc_inst_data_inter` date DEFAULT NULL,
`loc_inst_time_vistoria_start` time DEFAULT NULL,
`loc_inst_time_vistoria_end` time DEFAULT NULL,
`loc_inst_time_inter_start` time DEFAULT NULL,
`loc_inst_time_inter_end` time DEFAULT NULL,
`check_list_p_agua` int(1) DEFAULT '0',
`check_list_t_agua` int(1) DEFAULT '0',
`check_list_p_dist` varchar(3) DEFAULT NULL,
`check_list_obs` text,
`final_obs` text,
`vendedor` int(4) DEFAULT NULL,
`dt_aceito` int(1) DEFAULT NULL,
`bonus` text,
`anulado` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
트리거 정의를 표시하는 것은 어떻습니까? 우리는 당신을 위해 하나를 쓰지 않을 것이지만, 당신이 지금까지 한 일을 고치는 것을 도울 것입니다. –
정확한 코드는 무엇입니까? 나는 "create trigger'로 시작하는 라인을 의미합니다. http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html – Nanne
질문에 테이블 및 트리거 정의를 추가 할 수 있습니까? 당신이 게시 한 쿼리가'formulario' 테이블에 트리거의 본문이 아니길 바란다 ... – a1ex07