#1415 - 不允许从触发器返回结果集

时间:2015-03-09 11:22:22

标签: mysql

DELIMITER $$
CREATE TRIGGER `msg_after_insert` 
AFTER INSERT ON `meter_reading` 
FOR EACH ROW 
BEGIN 
select meter_reading.*,a.amount as Light_Reading_Amt,b.amount as Power_Reading_Amt from meter_reading inner join master_unit a on a.min_unit<=msg1 and msg1<=a.max_unit and doc>=a.date_of_enter_value_fm inner join master_unit b on b.min_unit<=msg2 and msg2<=b.max_unit and doc<=b.date_of_enter_value_to; 

INSERT INTO `smsd`.`outbox` (DestinationNumber,TextDecoded) VALUES (NEW.mobno, CONCAT_WS(NEW.msg1,NEW.Light_Reading_Amt,' ',NEW.msg2,NEW.Light_Reading_Amt)); 
END $$
DELIMITER ; 

我的数据库是 1. mr_sms(表格为:1.meter_reading 2.master_unit) --meter_reading表 -

CREATE TABLE IF NOT EXISTS `meter_reading` (
  `serno` int(50) NOT NULL AUTO_INCREMENT,
  `cno` varchar(50) DEFAULT NULL,
  `accn_no` varchar(20) DEFAULT NULL,
  `loc` varchar(20) DEFAULT NULL,
  `type_of_accn` varchar(50) NOT NULL,
  `rank` varchar(25) NOT NULL,
  `name` varchar(50) DEFAULT NULL,
  `mobno` varchar(15) DEFAULT NULL,
  `msg1` int(100) DEFAULT NULL,
  `msg2` int(250) NOT NULL,
  `status` varchar(30) NOT NULL,
  `doc` date NOT NULL,
  `remarks` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`serno`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;

--master_unit table--
CREATE TABLE IF NOT EXISTS `master_unit` (
  `u_id` int(11) NOT NULL AUTO_INCREMENT,
  `min_unit` int(150) NOT NULL,
  `max_unit` int(200) NOT NULL,
  `rate` varchar(20) NOT NULL,
  `amount` varchar(20) NOT NULL,
  `duty` varchar(20) NOT NULL,
  `dutyamount` varchar(20) NOT NULL,
  `date_of_enter_value_fm` date NOT NULL,
  `date_of_enter_value_to` date NOT NULL,
  PRIMARY KEY (`u_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

2. smsd  (table is : outbox)
--
-- Table structure for table `outbox`
--

CREATE TABLE IF NOT EXISTS `outbox` (
  `UpdatedInDB` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `InsertIntoDB` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SendingDateTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SendBefore` time NOT NULL DEFAULT '23:59:59',
  `SendAfter` time NOT NULL DEFAULT '00:00:00',
  `Text` text,
  `DestinationNumber` varchar(20) NOT NULL DEFAULT '',
  `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL DEFAULT 'Default_No_Compression',
  `UDH` text,
  `Class` int(11) DEFAULT '-1',
  `TextDecoded` text NOT NULL,
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `MultiPart` enum('false','true') DEFAULT 'false',
  `RelativeValidity` int(11) DEFAULT '-1',
  `SenderID` varchar(255) DEFAULT NULL,
  `SendingTimeOut` timestamp NULL DEFAULT '0000-00-00 00:00:00',
  `DeliveryReport` enum('default','yes','no') DEFAULT 'default',
  `CreatorID` text NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `outbox_date` (`SendingDateTime`,`SendingTimeOut`),
  KEY `outbox_sender` (`SenderID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `outbox`

-

0 个答案:

没有答案