English 中文(简体)
储存的我的舱面功能的奇怪问题
原标题:
  • 时间:2009-05-27 00:22:16
  •  标签:

它只是检验,

但奇怪的是:

    DELIMITER |

DROP FUNCTION IF EXISTS get_idiscussion_ask|

CREATE FUNCTION get_idiscussion_ask(iask_id INT UNSIGNED) RETURNS TEXT DETERMINISTIC
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE body varchar(600);
  DECLARE created DATETIME;
  DECLARE anonymous TINYINT(1);
  DECLARE screen_name varchar(64);
  DECLARE result TEXT;
  DECLARE cur1 CURSOR FOR SELECT body,created,anonymous,screen_name from idiscussion left join users on idiscussion.uid=users.id where idiscussion.iask_id=iask_id;
  DECLARE CONTINUE HANDLER FOR SQLSTATE  02000  SET done = 1;

  SET result =   ;
  OPEN cur1;
  REPEAT
    FETCH cur1 INTO body, created, anonymous, screen_name;
    SET result = CONCAT(result, <comment><body><![CDATA[ ,body, ]]></body> , <replier> ,if(screen_name is not null and !anonymous,screen_name,  ), </replier> , <created> ,created, </created></comment> );
  UNTIL done END REPEAT;
  CLOSE cur1;

  RETURN result;
END |

DELIMITER ;

mysql> DELIMITER ;
mysql> select get_idiscussion_ask(1);
+------------------------+
| get_idiscussion_ask(1) |
+------------------------+
| NULL                   |
+------------------------+
1 row in set (0.01 sec)



mysql> SELECT body,created,anonymous,screen_name from idiscussion left join users on idiscussion.uid=users.id where idiscussion.iask_id=1;
+------+---------------------+-----------+-------------+
| body | created             | anonymous | screen_name |
+------+---------------------+-----------+-------------+
| haha | 2009-05-27 04:57:51 |         0 | NULL        |
| haha | 2009-05-27 04:57:52 |         0 | NULL        |
| haha | 2009-05-27 04:57:52 |         0 | NULL        |
| haha | 2009-05-27 04:57:53 |         0 | NULL        |
+------+---------------------+-----------+-------------+
4 rows in set (0.00 sec)
问题回答

你们应该这样做。

Select Result

(1) 您不以你为榜样。

(2) 没收任何结果无效的物品

页: 1 如果你甚至不说的话,所储存的程序与它有什么关系?

如果你改变这一状况:

DECLARE cur1 CURSOR FOR 
  SELECT body,created,anonymous,screen_name 
  FROM idiscussion 
  LEFT JOIN users ON idiscussion.uid=users.id 
  WHERE idiscussion.iask_id=iask_id;

纽约总部

DECLARE cur1 CURSOR FOR SELECT   
ifnull(body,  )  
,ifnull(created,now())    
,ifnull(anonymous,0)  
,ifnull(screen_name,  )  
FROM idiscussion   
LEFT JOIN users on idiscussion.uid=users.id   
WHERE idiscussion.iask_id=iask_id;

你不应该在《废除酷刑公约》方面有任何问题。

also I m wondering if this part
where idiscussion.iask_id=iask_id;
does not give a name conflict maybe you should change the parameter
iask_id 纽约总部
piask_id
(but I m not sure on that part).





相关问题
热门标签