如何在MySQL中的存储过程中生成异常?例如:
CREATE PROCEDURE SALES()
BEGIN
STATEMENT...
STATEMENT...
STATEMENT...
IF (PRICE >= 500) THEN
/** THROWS AN EXCEPTION....
WHAT DO TO STOP THE PROCEDURE. **/
END IF;
STATEMENT...
STATEMENT...
STATEMENT...
END;
Run Code Online (Sandbox Code Playgroud)
在MySQL中我认为没有办法在存储过程中抛出异常,但我可以通过从不存在的表中选择来强制错误.例如:
IF (PRICE > 500) THEN
/*throw the error here*/
SELECT * FROM price_greater_than_500_in_throw_exception;
END IF;
Run Code Online (Sandbox Code Playgroud)
有更优雅的方式吗?
谢谢.
我有一个很大的问题(显然很容易解决),我已经尝试了超过24小时来创建一个函数来将数组转换为多维深度.
我的阵列是
$array = array(
array("name" => "Root_1", "depth"=> "1"),
array("name" => "Children","depth"=> "2"),
array("name" => "Children", "depth"=> "2"),
array("name" => "Children", "depth"=> "2"),
array("name" => "Children","depth"=> "3"),
array("name" => "Children","depth"=> "3"),
array("name" => "Children","depth"=> "3"),
array("name" => "Root_2", "depth"=> "1"),
array("name" => "Children", "depth"=> "2"),
array("name" => "Children", "depth"=> "2"),
array("name" => "Children", "depth"=> "2")
)
Run Code Online (Sandbox Code Playgroud)
我希望输出为:
$array = array(
array("name" => "Root_1", "depth"=> "1", "children" => array(
array("name" => "Children", "depth"=> "2", "children" => array()),
array("name" …Run Code Online (Sandbox Code Playgroud) 尝试理解为什么在alert("hello")多次单击后不生成函数真是太棒了...有一些方法可以执行此功能吗?
请注意,使用html()涉及按钮中的id"按" 更新后不起作用.
任何的想法?请参阅:http://jsbin.com/atuqu3
JavaScript的:
$(document).ready(function (){
$("#press").click(function() {
$("#relation-states").html('<select id="state" name="state"> <option value="Texas">Texas</option> </select><button id="press" type="button" title="" aria-haspopup="true" style="width: 175px;"><span>Select an item</span></button>');;
alert("hello");
});
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="relation-states">
<select id="state" name="state">
<option value="New York">New York</option>
</select>
<button id="press" type="button" title="" aria-haspopup="true" style="width: 175px;"><span>Select an item</span></button>
</div>
Run Code Online (Sandbox Code Playgroud)