mysql建立修改表存储过程_mysql里建立一个存储过程来实现对某个表的插入,修改,删除,查询操作...

//事务处理在PHP+MySQL中的用法实例

include( "../function/config.php ");

header( "Content-Type:text/html;charset=big5 ");

if(!(UserRight(5,10,1))){header( "Location:../Administrator/select.php ");}

?>

$StockInCode   =   $_POST[ "StockInCode "];

$StockInDate   =   $_POST[ "StockInDate "];

$PartnerCode   =   $_POST[ "PartnerCode "];

$SiteID     =   $_POST[ "SiteID "];

$Remarks   =   $_POST[ "Remarks "];

$CreateUserID   =   $_SESSION[ 'Userid '];

$CreateDate   =   date( "Y-m-d   H:i:s ");

$input_num   =   $_POST[ "input_num "];

$sql= "select   *   from   stockin   where   StockInCode= '$StockInCode ' ";

$result=mysql_fetch_row(mysql_query($sql));

if($result)

{

echo   ( " ");

exit();

}

else

{

mysql_query( "SET   AUTOCOMMIT=0 ");

mysql_query( "BEGIN ");

for   ($i=0;$i

$ProgramCode   =   $_POST[ "ProgramCode ".$i];

$ItemCode   =   $_POST[ "ItemCode ".$i];

$ItemQTY   =   $_POST[ "ItemQTY ".$i];

if(empty($ItemQTY)){

$ItemQTY   =   0;

}

if(!(empty($ProgramCode))){

$sql_sb   =   "select   *   from   stockbalance   where   PartnerCode= '$PartnerCode '   and   ProgramCode= '$ProgramCode '   and   ItemCode= '$ItemCode '   and   SiteID= '$SiteID ' ";

$result_sb   =   mysql_fetch_row(mysql_query($sql_sb));

if($result_sb){

$sql_up_sb   =   "update   stockbalance   set   QTY=QTY+$ItemQTY,UpdateUserID= '$CreateUserID ',LastUpdate= '$CreateDate '   where   PartnerCode= '$PartnerCode '   and   ProgramCode= '$ProgramCode '   and   ItemCode= '$ItemCode '   and   SiteID= '$SiteID ' ";

//echo   $sql_up_sb. "
";

//mysql_query($sql_up_sb);

if(!mysql_query($sql_up_sb)){mysql_query( "ROOLBACK ");}

}else{

$sql_in_sb= "insert   into   stockbalance   (PartnerCode,SiteID,ProgramCode,ItemCode,QTY,CreateUserID,CreateDate)   values( '$PartnerCode ', '$SiteID ', '$ProgramCode ', '$ItemCode ', '$ItemQTY ', '$CreateUserID ', '$CreateDate ') ";

//echo   $sql_in_sb. "
";

//mysql_query($sql_in_sb);

if(!mysql_query($sql_in_sb)){mysql_query( "ROOLBACK ");}

}

$sql_il   =   "insert   into   stockinitem   (PartnerCode,SiteID,ProgramCode,StockInCode,ItemCode,QTY)   values( '$PartnerCode ', '$SiteID ', '$ProgramCode ', '$StockInCode ', '$ItemCode ', '$ItemQTY ') ";

//echo   $sql_il. "
";

//mysql_query($sql_il);

if(!mysql_query($sql_il)){mysql_query( "ROOLBACK ");}

}

}

$sql_is= "insert   into   stockin   (StockInCode,StockInDate,PartnerCode,SiteID,Remarks,CreateUserID,CreateDate)   values( '$StockInCode ', '$StockInDate ', '$PartnerCode ', '$SiteID ', '$Remarks ', '$CreateUserID ', '$CreateDate ') ";

//echo   $sql_is. "
";

//mysql_query($sql_is);

if(!mysql_query($sql_is)){mysql_query( "ROOLBACK ");}

mysql_query( "COMMIT ");

echo   ( " ");

}

?>

作者: yangyu112654374

发布时间: 2007-07-06

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值