<%
__header("Content-Type","text/html; charset=gb2312");
var serr="{\"op\":\"op err\"}";
if (op=="")
  write(serr);
else
{
var sql;
var iupd=-1;
db_Open("/NandFlash/dbCfg.db3");
if (op=="upd")
{
  if (db_QryInt("select count(*) from tbAlm where AID="+aid,1)==0)
    db_UpdAdv("insert into tbAlm(AID) values("+aid+")",1);
  sql = "update tbAlm set "+setval+" where AID="+aid;
  iupd=db_UpdAdv(sql,1);
  var isid=sid;
  if (isid==0)
    isid=db_QryLastRowId();
  db_UpdAdv("update tbSM set AID="+aid+" where SID="+isid,1);
}

if (iupd<0 && iupd!=-1)
  write(serr);
if (iupd>=0)
{
  var lastId = db_QryLastRowId();
  write("{\"op\":\"ok\",\"sid\":"+lastId+"}");
}
db_Close();
}
%>