MySQL與MSSQl應用While語句輪回生成測試數據的代碼。本站提示廣大學習愛好者:(MySQL與MSSQl應用While語句輪回生成測試數據的代碼)文章只能為提供參考,不一定能成為您想要的結果。以下是MySQL與MSSQl應用While語句輪回生成測試數據的代碼正文
在MySQL中,應用While語句輪回與SQL Server中有所分歧,代碼測試經由過程。
MSSQL中應用while語句輪回生成數據的辦法:
示例代碼:
declare @a int
set @a = 1
while @a<25
begin
INSERT INTO demotable (id,item1,item2) VALUES (@a,"abc","123")
set @a = @a + 1
end
MySQL中,應用while輪回處置數據辦法:須要新建為存儲進程,直接挪用履行存儲進程。
示例代碼:
CREATE DEFINER=`root`@`localhost` PROCEDURE `NewProcedure`()
BEGIN
DECLARE i INT;
SET i=1;
WHILE i<100 DO
INSERT INTO demotable (id,item1,item2) VALUES (i,"測嘗嘗題","0");
SET i = i + 1;
END WHILE;
END;
[i].a;
row.insertCell(1).innerHTML =" "+msg[i].b;
row.insertCell(2).innerHTML =" "+msg[i].c;
row.insertCell(3).innerHTML =" "+msg[i].d;
row.insertCell(4).innerHTML =" "+msg[i].e;
row.insertCell(5).innerHTML =" "+msg[i].f;
row.insertCell(6).innerHTML =" "+msg[i].g;
row.insertCell(7).innerHTML =" "+msg[i].h;
row.insertCell(8).innerHTML =" "+msg[i].i;
row.setAttribute("align", "center");
}
tab_id.style.display="block";
}else{
tab_id.innerHTML="<center>負疚,該卡未守舊,獲得不到租還車信息!</center>";
tab_id.style.width = "80%";
tab_id.style.position = "absolute";//相對地位顯示
tab_id.style.display="block";
}
removeDiv();
}
//遮罩層顯示
displayDiv=function()
{
var mybg = document.createElement("div");
mybg.setAttribute("id","mybg");
mybg.innerHTML="<center>正在處置中, 請稍候<img src='lib/images/loading.gif'></img></center>";
mybg.style.width = "100%";
mybg.style.position = "absolute";//相對地位顯示
mybg.style.top = "260";
mybg.style.left = "0";
mybg.style.zIndex = "100";//z軸地位
mybg.style.opacity = "0.8";//通明度
mybg.style.filter = "Alpha(opacity=80)";//濾鏡顯示通明度
document.body.appendChild(mybg);
}
//遮罩層移除
removeDiv=function()
{
document.body.removeChild(mybg);
}
java後台存入json對象:
/**
* 依據卡內碼獲得比來的租還車記載
* 前往json對象
* @param cardInNo
* @return
*/
public String getRefInfo(String cardInNo)
{
StringBuffer bf=new StringBuffer(1024);
bf.append("");//sql語句
System.out.println(bf.toString());
/************ 存儲json對象***************/
List<JSONObject> jsonList=new ArrayList<JSONObject>();
try {
/****************取得斷定信息存入數組中*******************/
String [][] str=getArrayByName(bf.toString());
if(str!=null){
for (int i = 0; i < str[0].length; i++) {
JSONObject returnValue =new JSONObject();
returnValue.put("a", str[0][i])
.put("b", str[1][i])
.put("c", str[2][i].trim().equals("")?"":str[2][i].substring(0, 19))
.put("d", str[3][i].trim().equals("")?"":str[3][i].substring(0, 19))
.put("e", str[4][i])
.put("f", str[5][i])
.put("g", str[6][i])
.put("h", str[7][i])
.put("i", str[8][i]);
jsonList.add(returnValue);
}
}
}catch (Exception e) {
e.printStackTrace();
}
System.out.println(jsonList.toString());
return jsonList.toString();
}
願望本文所述對年夜家ajax法式設計有所贊助。