毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 数据库 >> 正文

DECLARE rs CURSOR FOR SELECT * from LQL170;说附近有语法错误

更新时间:2012-10-30:  来源:毕业论文

DECLARE rs CURSOR FOR SELECT * from LQL170;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET Done = 1;

我在存储过程中定义游标,一保存,就是 DECLARE rs CURSOR FOR SELECT * from LQL170;说附近有语法错误,刚需写的 请大神多多指教
DELIMITER $$
CREATE PROCEDURE testa()
BEGIN
  DECLARE sqlStr1 VARCHAR(2000);
  DECLARE i INT(10) DEFAULT 0;
  DECLARE k INT(10) DEFAULT 0;
  DECLARE Done INT DEFAULT 0;
  DECLARE seltable VARCHAR(2000);
  DECLARE _mon VARCHAR(20);
  DECLARE _bh VARCHAR(20);
  DECLARE _xm VARCHAR(100);
  DECLARE _bm VARCHAR(20);
  DECLARE _gw VARCHAR(20);
  DECLARE _jj VARCHAR(20);
  DECLARE rs CURSOR FOR SELECT SYBH,XM,BMBH,GW FROM LQL170;
  DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET Done = 1;
   
  DROP TABLE IF EXISTS tab_Ltext;

  SET seltable='';hindi sms sms
  SET sqlStr1='';
  SET @sqlStr1 = CONCAT('CREATE TABLE tab_Ltext(month1 VARCHAR(20), bh VARCHAR(10),xm VARCHAR(100),bm VARCHAR(20),gw VARCHAR(100),jj VARCHAR(10))');
  PREPARE s FROM @sqlStr1;
  EXECUTE s;


  SELECT COUNT(*)INTO i FROM LQL170;
  SET @seltable = CONCAT('select',' SYBH,XM,BMBH,GW,SCQF,TSRQ from LQL170 ');
  -- INSERT INTO tab_Ltext(month1,bh,xm,bm,gw,jj)VALUES('2012','','','','','');
 PREPARE s1 FROM @seltable;
  EXECUTE s1;

  SELECT COUNT(*) INTO i FROM LQL170;

  
  OPEN rs;
  REPEAT
  FETCH NEXT FROM rs INTO _bh,_xm ,_bm,_gw ;  
  INSERT INTO tab_Ltext(month1,bh,xm,bm,gw,jj) VALUES ('2012/10',_bh,_xm,_bm,_gw,'1000');

  SET i =i - 1;
  UNTIL i =0 END REPEAT;
  CLOSE rs;

  SELECT * FROM tab_Ltext;
  -- SELECT i ;
END$$
DELIMITER ;

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。